-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix double-taping on iPad to open popover in Quick Order List #2934
Conversation
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.
This works beautifully on my iPad @eugenekasimov— great work!
Also, tested on my phone and on Desktop for any regressions... everything's looking solid. Thanks!
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.
This works great! Left some small feedback in case you decide to change the variable name.
@@ -11,6 +11,7 @@ if (!customElements.get('quantity-popover')) { | |||
this.popoverInfo = this.querySelector('.quantity-popover__info'); | |||
this.closeButton = this.querySelector('.button-close'); | |||
this.variantInfo = this.querySelector('.quantity-popover-container'); | |||
this.eventMouseEnterHappened = false; |
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.
Small nitpick but maybe we can simplify this to just this.mouseEnterCompleted
as it conveys that the variable is related to the completion of the mouseenter
event.
@@ -37,6 +39,11 @@ if (!customElements.get('quantity-popover')) { | |||
|
|||
togglePopover(event) { | |||
event.preventDefault(); | |||
if (event.type === 'mouseenter') { |
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.
Small suggestion: Maybe we can convert these to variables
this.actions = {
mouseEnter: 'mouseenter',
click: 'click'
}
And refer to it as this.actions.click
and this.actions.mouseEnter
throughout the file
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.
I don't see we use it a lot in the file, we use it only in one function. Am I getting you right that you suggest we do it this way? I'm not sure if it's worth it but I'm okay if everyone agrees.
if (event.type === 'mouseenter') { | |
this.actions = { | |
mouseEnter: 'mouseenter', | |
click: 'click' | |
} | |
if (event.type === this.actions.mouseEnter) { | |
this.eventMouseEnterHappened = true; | |
} | |
if (event.type === this.actions.click && this.eventMouseEnterHappened) return; | |
const button = this.infoButtonDesktop && this.mql.matches ? this.infoButtonDesktop : this.infoButtonMobile; | |
const isExpanded = button.getAttribute('aria-expanded') === 'true'; | |
button.setAttribute('aria-expanded', !isExpanded); | |
this.popoverInfo.toggleAttribute('hidden'); | |
const isOpen = button.getAttribute('aria-expanded') === 'true'; | |
button.classList.toggle('quantity-popover__info-button--open'); | |
if (isOpen && event.type !== this.actions.mouseEnter) { | |
button.focus(); | |
} |
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.
That is fair! We can keep it as is, but if we repeat it more often throughout the file we can change that
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.
Looks good! Added a small suggestion
* upstream/main: (205 commits) Fix for small screens with large fonts don't fit all content (Shopify#2946) Adjust quantity rules margin (Shopify#2948) Update Social media settings defaults to remove Shopify links (Shopify#2830) added json to barcode to pass gtin as a json string (Shopify#2804) Fixed extra margin spacing in collage section when header is empty (Shopify#2770) Track state of mouseenter event (Shopify#2934) Fix misalignment of total items in quick order list (Shopify#2923) Hide vol pricing and qty rules when variant is unavailable (Shopify#2889) Fix font family for quick order list (Shopify#2888) v11.0.0 version bump and release notes (Shopify#2916) Revert "v11.0.0 version bump and release notes (Shopify#2906)" (Shopify#2915) Update quantity-popover.css v11.0.0 version bump and release notes (Shopify#2906) Fix social list styles loading (Shopify#2900) Fix an error (Shopify#2903) Fix hardcoded info color (Shopify#2893) Fix error misalignment for Quick order list (Shopify#2887) Replace generic section name with section ID. (Shopify#2884) Fix cart drawer for variant list and tablet spacing (Shopify#2880) Add missing shadow styles to inputs in Quick Order List (Shopify#2879) ...
PR Summary:
This PR fixes the issue when you need to tap twice on
info-icon
on iPad(tablets) in order to open the popover.Why are these changes introduced?
Fixes #2890.
What approach did you take?
There was a conflict between two event listeners
mouseenter
andclick
that fired the same function same time. On iPad when you tap an element both events are fired, firstmouseenter
and thenclick
.We still need to keep them both because we have to cover cases for mouse and keyboard users and iPad and Desktop may have the same screen size.
I added a variable
eventMouseEnterHappened
to track a state of themouseenter
event. Now, if themouseenter
happens theclick
event won't be fired untileventMouseEnterHappened
is reset.Other considerations
Decision log
Visual impact on existing themes
Testing steps/scenarios
info-icon
test that popover element appears as expected.info-icon
.Demo links
Checklist