-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
[Experimental] [CYS - Full Composability]: Add tooltip when user clicks on pattern #47583
[Experimental] [CYS - Full Composability]: Add tooltip when user clicks on pattern #47583
Conversation
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
Size Change: 0 B Total Size: 2.47 MB |
02038a1
to
677cc56
Compare
…-pattern' of github.com:woocommerce/woocommerce into 47455-cys-full-composability-add-tooltip-on-the-hovered-pattern
8e1ce74
to
2c5bc64
Compare
…-cys-full-composability-add-tooltip-on-the-hovered-pattern
Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
I noticed that enabling the mousemove event , the console throws multiple errors: DCkwyz.mp4This is caused by the Also, I think that the quickest fix is to change this check to |
…-cys-full-composability-add-tooltip-on-the-hovered-pattern
…-cys-full-composability-add-tooltip-on-the-hovered-pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @gigitux !
I've confirmed everything works as described:
Screen.Recording.2024-06-05.at.13.55.08.mov
Not a blocker, but a thought: whenever hovering over the sidebar and going back to the main frame, I see the tooltip is still displayed even without any new click on the pattern: should we change this to, if the pointer is moved away from the frame and then back, the tooltip is displayed again only on click?
Thanks for catching this, @nefeline! I agree with you. Given that the PR is already very big, I'm going to create a dedicated issue to fix this! |
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR adds a tooltip when the user clicks on a pattern.
Closes #47455 #47453.
This PR adds the tooltip when the user clicks on a pattern. This work required some refactoring, given that I had to optimize the functions that are called during each render to avoid a sluggish user experience.
usePopoverHandler
I added
usePopoverHandle
hook to handle the computation of the position of the popover based on the pointeruseAddAutoBlockPreviewEventListenersAndObservers
I added
useAddAutoBlockPreviewEventListenersAndObservers
to centralize all the hooks and mutationObservers in one place. Furthermore, I ensured that mutation observers are called only when necessary, given that they hurt performance (example: https://github.com/woocommerce/woocommerce/blob/693b153fc00ffbb9d9758f69c3e81c16c28c38a3/plugins/woocommerce-admin/client/customize-store/assembler-hub/hooks/auto-block-preview-event-listener.ts/#L258-L259).Also, I ensured that we unsubscribe them when the component is unmounted. This is really important because the
AutoHeightBlockPreview
component is used for the main iframe and the small previews in the sidebar.Futhermore, I created two new functions:
addInertToAllInnerBlocks
: this function adds theinert
attribute to all the inner blocks, in this way, the browser will ignore those elements: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert.updateSelectedBlock
: updates the selected block when the user interacts with it.Removed not used code
Removed unused code related to the "other pages" feature, which wasn't shipped in the initial CYS version: https://github.com/woocommerce/woocommerce/pull/47583/files#diff-2320f0b44212379f7b24fd69a40a3b7ab6be829ea02c507d3c81de35c4948cc5L128-L165
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
pattern-toolkit-full-composability
on the list.LofFz5.mp4
Changelog entry
Significance
Type
Message
CYS: Show popover when the user clicks on the pattern
Comment