-
Notifications
You must be signed in to change notification settings - Fork 206
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: add delay to overlay-trigger #3748
Conversation
Tachometer resultsChromeaction-bar permalink
action-menu permalink
menu permalink
overlay permalink
picker permalink
popover permalink
split-button permalink
tooltip permalink
Firefoxaction-bar permalink
action-menu permalink
menu permalink
overlay permalink
picker permalink
popover permalink
split-button permalink
tooltip permalink
|
I think we could centralize this change by updating https://github.com/adobe/spectrum-web-components/blob/main/packages/overlay/src/Overlay.ts#L97-L98 to be a getter/setter and have the getter check the |
@Westbrook Something like the new refactoring ? 👀 |
packages/overlay/src/Overlay.ts
Outdated
return true; | ||
} | ||
|
||
return this._delayed; |
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.
Is this all enough the same as return this.elements.at(-1)?.hasAttribute('delayed') ?? this._delayed;
?
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.
Almost, changed to this.elements.at(-1)?.hasAttribute('delayed') || this._delayed;
It would be nice if we could add a test for this. Maybe there's room to add a little time checking between the hover and open events in https://github.com/adobe/spectrum-web-components/blob/main/packages/overlay/test/overlay-trigger-hover-click.test.ts#L92-L111 or so. Probably can go without blocking on this, but maybe you've got an idea on testing this other wise? After that, I think we're just missing some changes from |
70d1038
to
b2b11d1
Compare
@Westbrook Rebased with main + added a test for delay on click ✅ |
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.
Looking good! Tiny refactor in the test for simplicity, and then let's ship it!
el.setAttribute('open', 'click'); | ||
await waitUntil( | ||
() => openedSpy.calledOnce, | ||
'hover content projected to overlay', | ||
{ timeout: 8000 } | ||
); |
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.
el.setAttribute('open', 'click'); | |
await waitUntil( | |
() => openedSpy.calledOnce, | |
'hover content projected to overlay', | |
{ timeout: 8000 } | |
); | |
const start = performance.now(); | |
const opened = oneEvent(el, 'sp-opened'); | |
el.setAttribute('open', 'click'); | |
await opened; |
If you structure the test like this you can get away without either of the spies and can be sure to only test the open workflow, rather than any delay that might come from the generation of the fixture.
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.
LGTM! Thanks for bringing this to our attention and finding such a clean fix. 🙇🏼
This PR adds the
delay
capability back tooverlay-trigger
Motivation and context
Adding back the capability of delayed overlays.
How has this been tested?
Test case 1
Inside storybook created a button with a delayed tooltip through overlay-trigger.
Test case 2
Called the Overlay.open() method to test backwards compatibility.
Screenshots (if appropriate)
Types of changes
Checklist
Best practices
This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against
main
.