-
Notifications
You must be signed in to change notification settings - Fork 77
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
refactor(modal): Update modal to use focus-trap module. #5676
Changes from 12 commits
2355312
b31109c
4a6b6c0
104492f
462d81a
91bf8f3
599fdc4
2a98931
b51bfda
ba6c2e8
886cde8
cd3ca2d
6a607e4
5c75164
464e287
bdb7c4b
533c136
8dd9662
9f6e99e
4b17306
1abe776
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ export const SLOTS = { | |
export const TEXT = { | ||
close: "Close" | ||
}; | ||
|
||
export const ANIMATION_TIMEOUT = 300; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,11 @@ interface FocusableOptions { | |
* selector used to assert the focused shadow DOM element | ||
*/ | ||
shadowFocusTargetSelector?: string; | ||
|
||
/** | ||
* Used to delay setFocus call in ms. | ||
*/ | ||
delay?: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is for the open/close transition, I'd suggest using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jcfranco the problem is the I tried
|
||
} | ||
|
||
/** | ||
|
@@ -210,6 +215,10 @@ export async function focusable(componentTagOrHTML: TagOrHTML, options?: Focusab | |
const element = await page.find(tag); | ||
const focusTargetSelector = options?.focusTargetSelector || tag; | ||
|
||
if (options?.delay) { | ||
await page.waitForTimeout(options.delay); | ||
} | ||
|
||
await element.callMethod("setFocus", options?.focusId); // assumes element is FocusableElement | ||
|
||
if (options?.shadowFocusTargetSelector) { | ||
|
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.
Since
close-button
is the only supported ID, I think you could just check forcloseButtonEl
being present or not. Passing any other ID would technically be invalid, right?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.
Correct. I think its nicer to check and fallback incase the user entered an invalid ID>