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

Block switch: ensure hover is reset when style changed #12317

Merged
merged 1 commit into from
Jan 29, 2019

Conversation

johngodley
Copy link
Contributor

The block style picker is used by a block's toolbar to allow the style to be changed. As you hover over a style it sends a onHoverClassName event to BlockSwitcher indicating which style is being hovered over, which is then used to show a preview.

edit_post_ _wordpress_latest_ _wordpress

When you click on a style the BlockSwitcher is hidden but retains its last state, including the hover style.

If you show the BlockSwitcher again it will appear with a hover style and preview already selected

This PR sends a onHoverClassName event when a style is picked, ensuring the BlockSwitcher component is reset.

Fixes #12225

How has this been tested?

  1. Create a button block and enter some details
  2. Click the block style icon in the block toolbar (not the sidebar)
  3. Pick a style
  4. Click the block style icon again and verify that the preview is not shown
  5. Verify that the block style picker in the sidebar functions as expected - nothing should change here as it doesnt show a preview

Types of changes

Non-breaking change to <BlockStyles/>

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

When a block style is selected we should reset the hover state so that any component using this will be adjusted accordingly
@johngodley johngodley added [Feature] Blocks Overall functionality of blocks [Status] In Progress Tracking issues with work in progress and removed [Status] In Progress Tracking issues with work in progress labels Nov 26, 2018
@johngodley johngodley requested a review from a team November 27, 2018 11:58
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for the fix.

@gziolo gziolo added this to the 5.0 (Gutenberg) milestone Jan 25, 2019
@youknowriad youknowriad merged commit 4a1fc6f into master Jan 29, 2019
@youknowriad youknowriad deleted the fix/block-switch-hover branch January 29, 2019 07:36
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
When a block style is selected we should reset the hover state so that any component using this will be adjusted accordingly
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
When a block style is selected we should reset the hover state so that any component using this will be adjusted accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants