Replies: 2 comments 2 replies
-
Does FocusScope support portaled elements? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I believe it just comes down to the fact that userEvent is not the same as my regular keyboard, while trying to test this with @storybook/test. My end config is: function Table() {
return <FocusScope><table></table></FocusScope>
} function ConfirmDialog() {
return (
<Dialog
onClose={onClose}
className={cn(className, styles.Modal, { [styles.Modal___backgroundClicked]: flash })}
{...props}
ref={ref}
hideOnInteractOutside={(e) => {
// Close the modal if the shouldCloseOnOverlayClick prop is true
if (shouldCloseOnOverlayClick) {
return true;
}
// Otherwise, give a little animation to let the user know they need to deal with the modal
setFlash(true);
e.preventDefault();
return false;
}}
store={dialog}
autoFocusOnHide={false}
backdrop={<div className={styles.Modal_overlay} data-testid="modal-overlay" />}
>
<FocusScope restoreFocus={true}>
<ModalProvider closeModal={onClose}>{children}</ModalProvider>
</FocusScope>
</Dialog>
);
} Which works when interacting manually, but not in tests. So maybe I need to fix my timings or adjust how I trigger keyboard events... |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using FocusScope to manage focus when deleting a row of my Table from an @ariakit/react Dialog.
I've wrapped my Table in a FocusScope, and wrapped my Dialog in
<FocusScope restoreFocus={true}>
. In certain situations it returns focus to the previous row fine, but in other situations it returns focus to the document root, which I'm trying to avoid.What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions