Skip to content
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(KvLightbox): allow focus on open alerts, clicks on browser extensions and outside lightbox #326

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

emuvente
Copy link
Collaborator

@emuvente emuvente commented Dec 6, 2023

The focus trap was preventing closing tip message toasts and preventing clicking outside the lightbox to close it.

Using the allowOutsideClick: true option allows clicking outside the focus trap, which then allows closing toasts and accessing elements added by browser extensions like password managers.

Including the '[role="alert"]' selector string in the focus trap array will include any open alerts in the focus trap, allowing for focusing on the alert close button using tab.

@emuvente emuvente requested a review from a team December 6, 2023 20:34
const {
activate: activateFocusTrap,
deactivate: deactivateFocusTrap,
} = useFocusTrap(kvLightbox);
} = useFocusTrap(trapElements, {
allowOutsideClick: true, // allow clicking outside the lightbox to close it
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be conditional based on props sent to the lightbox? We don't allow outside clicks in certain circumstances such as employee verification for campaign pages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't bypass our existing preventClose logic. If preventClose is true, clicking on the background won't close the lightbox. This just allows clicking on the background to close the lightbox when preventClose is false.

@emuvente emuvente merged commit 03cae32 into main Dec 6, 2023
1 of 2 checks passed
@emuvente emuvente deleted the fix-toast-and-lightbox branch December 6, 2023 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants