Skip to content

Preserve theme class #5823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2024
Merged

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Apr 3, 2024

This PR aims to fix a revdep failure reported in #5822.

Subsetting a theme drops the class:

library(ggplot2)
class(theme())
#> [1] "theme" "gg"
class(theme()[])
#> [1] "list"

Created on 2024-04-03 with reprex v2.1.0

We subsetted the theme in #5743 to drop unknown elements, but an extension (mine, guilty as charged) relied on classed behaviour of theme settings (invoking add_theme() via +). This PR replaced the subsetting operation with assigning NULL to unknown theme settings, preserving the class.

@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Apr 3, 2024
@teunbrand teunbrand requested a review from thomasp85 April 3, 2024 08:36
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit 1050f09 into tidyverse:main Apr 3, 2024
12 checks passed
@teunbrand teunbrand deleted the preserve_theme_class branch April 3, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants