Skip to content
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

Default custom color doesn't get saved #37861

Closed
javierarce opened this issue Jan 11, 2022 · 3 comments · Fixed by #54332
Closed

Default custom color doesn't get saved #37861

javierarce opened this issue Jan 11, 2022 · 3 comments · Fixed by #54332
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@javierarce
Copy link
Contributor

Description

Probably a minor bug, but if a user adds a custom color and doesn't move the color picker or change its name, the color is not saved.

Step-by-step reproduction instructions

  1. Go to the Global Styles
  2. Edit the theme palette
  3. Add a custom color by clicking the + icon
  4. Click done without modifying anything

Screenshots, screen recording, code snippet

palette_save.mp4

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@javierarce javierarce added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Jan 11, 2022
@annezazu
Copy link
Contributor

How strange! Seems similar to this previous problem (just to connect some dots): #36473

@annezazu annezazu added the [Type] Bug An existing feature does not function as intended label Jan 11, 2022
@javierarce
Copy link
Contributor Author

Thanks, Anne! It could also be somehow related to this PR

@t-hamano
Copy link
Contributor

I, too, think this behavior can be treated as a bug.

In the current spec, if the color palette name conforms to the rule of Color {number} and is the default color (#000), then it is considered a temporary color and that color is removed when the "Done" button is pressed.

function isTemporaryElement(
slugPrefix: string,
{ slug, color, gradient }: Color | Gradient
) {
const regex = new RegExp( `^${ slugPrefix }color-([\\d]+)$` );
return (
regex.test( slug ) &&
( ( !! color && color === DEFAULT_COLOR ) ||
( !! gradient && gradient === DEFAULT_GRADIENT ) )
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants