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 1 commit into from Jan 29, 2019


None yet
3 participants
Copy link

johngodley commented Nov 26, 2018

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/>


  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
Block switch: ensure hover is reset when style changed
When a block style is selected we should reset the hover state so that any component using this will be adjusted accordingly

@johngodley johngodley requested a review from WordPress/gutenberg-core Nov 27, 2018

Copy link

youknowriad left a comment

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@youknowriad youknowriad deleted the fix/block-switch-hover branch Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment