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

Allow to deselect color in ColorPickerWidget. #4839

Merged
merged 4 commits into from
Jun 14, 2023

Conversation

ksuess
Copy link
Member

@ksuess ksuess commented Jun 1, 2023

fix #4838

Would be nice to be able to de-select a color in a general color picker widget.

@ksuess ksuess self-assigned this Jun 1, 2023
@netlify
Copy link

netlify bot commented Jun 1, 2023

Deploy Preview for volto canceled.

Name Link
🔨 Latest commit 9e3006e
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/6489f80bf972af0008a1908a

@ksuess
Copy link
Member Author

ksuess commented Jun 1, 2023

I think this is the right approach, would you check please, @tiberiuichim, @sneridagh, thanks.

@cypress
Copy link

cypress bot commented Jun 1, 2023

Passing run #5383 ↗︎

0 493 20 0 Flakiness 0

Details:

Merge branch 'master' into allow-deselect-color-in-ColorPickerWidget
Project: Volto Commit: a3ec5c148e
Status: Passed Duration: 14:28 💡
Started: Jun 1, 2023 5:07 PM Ended: Jun 1, 2023 5:22 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@sneridagh
Copy link
Member

@ksuess Did you try how does this behave when you have a color by default set? I would do that under a prop, since could be that you really want to have one by default, and do not allow to remove it.

@ksuess
Copy link
Member Author

ksuess commented Jun 1, 2023

@ksuess Did you try how does this behave when you have a color by default set? I would do that under a prop, since could be that you really want to have one by default, and do not allow to remove it.

Respect missing_value of ColorPickerWidget on de-select

@ksuess ksuess requested a review from sneridagh June 1, 2023 17:04
@ksuess
Copy link
Member Author

ksuess commented Jun 1, 2023

Please backport to Volto 16.

@ksuess
Copy link
Member Author

ksuess commented Jun 12, 2023

@ksuess Did you try how does this behave when you have a color by default set? I would do that under a prop, since could be that you really want to have one by default, and do not allow to remove it.

Respect missing_value of ColorPickerWidget on de-select

ping @sneridagh

@ksuess ksuess merged commit 28a753b into master Jun 14, 2023
@ksuess ksuess deleted the allow-deselect-color-in-ColorPickerWidget branch June 14, 2023 17:40
@sneridagh
Copy link
Member

@ksuess this is not what I meant... I still didn't have time to check it. Where the missing_value comes from? The question is:
Does this still work?

  const defaultBGColor = '#ddd';

  schema.properties.styles.schema.properties.backgroundColor = {
    widget: 'color_picker',
    title: intl.formatMessage(messages.backgroundColor),
    colors,
    default: defaultBGColor,
  };

@sneridagh
Copy link
Member

@ksuess I tested it out and the defaults work as expected. Nevertheless, what is for missing_value?
Could you please add a PR to backport it to 16?

sneridagh pushed a commit that referenced this pull request Jun 15, 2023
sneridagh added a commit that referenced this pull request Jun 15, 2023
Co-authored-by: Katja Süss <k.suess@rohberg.ch>
@ksuess
Copy link
Member Author

ksuess commented Jun 16, 2023

@ksuess I tested it out and the defaults work as expected. Nevertheless, what is for missing_value?

With just default, the color value is default on deselect. Only with both default and missing_value it's possible to have a default on creating a new block, and having a fallback color value different from default value on de-select.

  const addMyCustomBlockColorStyling = ({ schema, intl }) => {
    addStyling({ schema, intl });

    schema.properties.styles.schema = {
      fieldsets: [
        {
          id: 'default',
          title: 'Default',
          fields: ['Background'],
        },
      ],
      properties: {
        Background: {
          title: 'Stil',
          widget: 'color_picker',
          default: 'blueBox',
          missing_value: 'grayBox',
          colors: [
            { name: 'greenBox', label: 'Ausserdem' },
            { name: 'blueBox', label: 'Bemerkung' },
            { name: 'grayBox', label: 'Wichtig' },
            { name: 'orangeBox', label: 'Achtung' },
          ],
        },
      },
      required: [],
    };

    return schema;
  };

sneridagh added a commit that referenced this pull request Jun 17, 2023
* master:
  Release 17.0.0-alpha.13
  Enforce max upload size (#4868)
  Fix and improve the `addStyling` helper (#4880)
  Release 17.0.0-alpha.12
  Fix regression in horizontal scroll in contents view, add it back (#4872)
  Configurable Container component from registry for some key route views. (#4871)
  Allow to deselect color in ColorPickerWidget. (#4839)
sneridagh added a commit that referenced this pull request Jun 25, 2023
* master:
  Release 17.0.0-alpha.14
  Linked headlines (#3540)
  Release notes for 16.20.8 16.21.0 16.21.1 (#4910)
  Spanish translation (#4896)
  Refactor Anontools (#4845)
  Update to plone-backend 6.0.5 (#4897)
  Release 17.0.0-alpha.13
  Enforce max upload size (#4868)
  Fix and improve the `addStyling` helper (#4880)
  Release 17.0.0-alpha.12
  Fix regression in horizontal scroll in contents view, add it back (#4872)
  Configurable Container component from registry for some key route views. (#4871)
  Allow to deselect color in ColorPickerWidget. (#4839)
  Release 17.0.0-alpha.11
  Pagination with router params (#4698)
  Release 17.0.0-alpha.10
  feat(slate): Add css identifier to slate style menu options (#4847)
  Update Brazilian Portuguese translations (Fixes #4853)
  Convert header class to function (#4767)
sneridagh added a commit that referenced this pull request Jun 26, 2023
* master: (29 commits)
  Remove anonymous function calls. Remove default exports from. (#4917)
  Release 17.0.0-alpha.14
  Linked headlines (#3540)
  Release notes for 16.20.8 16.21.0 16.21.1 (#4910)
  Spanish translation (#4896)
  Refactor Anontools (#4845)
  Update to plone-backend 6.0.5 (#4897)
  Release 17.0.0-alpha.13
  Enforce max upload size (#4868)
  Fix and improve the `addStyling` helper (#4880)
  Release 17.0.0-alpha.12
  Fix regression in horizontal scroll in contents view, add it back (#4872)
  Configurable Container component from registry for some key route views. (#4871)
  Allow to deselect color in ColorPickerWidget. (#4839)
  Release 17.0.0-alpha.11
  Pagination with router params (#4698)
  Release 17.0.0-alpha.10
  feat(slate): Add css identifier to slate style menu options (#4847)
  Update Brazilian Portuguese translations (Fixes #4853)
  Convert header class to function (#4767)
  ...
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.

Allow deselecting color in ColorPickerWidget
2 participants