Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: prevent scrolling when focus trap cycles back into the modal #82

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

Open
jquense wants to merge 2 commits into main
base: main
Choose a base branch
Loading
from modals

Conversation

@jquense
Copy link
Member

@jquense jquense commented Apr 24, 2023
edited
Loading

also fixes a small issue with the alertdialog role fixing #81 and addresses the bug noted in react-bootstrap/react-bootstrap#6579

I was hoping the scroll thing would be as simple as preventDefault on the incoming focus event but that doesn't seem to cut it in Chrome at least, so back to good ol manual scroll position setting.

also fixes a small issue with the `alertdialog` role

protected getScollingElement() {
const element = getScrollParent(this.getElement());
return isDocument(element) ? element.defaultView! : element;
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe this is over complicating things? people shouldn't actually be rendering modals into not-the-body

removeFocusListenerRef.current = listen(
document as any,
'focus',
// the timeout is necessary b/c this will run before the new modal is mounted
Copy link
Collaborator

@kyletsang kyletsang Apr 25, 2023

Choose a reason for hiding this comment

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

Looks like this was necessary to resolve the TypeError: Converting circular structure to JSON error in the tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'm confused why tho. It doesn't seem necessary in real life. Gotta dig in a bit

return getBodyScrollbarWidth(this.ownerDocument);
}

protected getScollingElement() {
Copy link
Collaborator

@kyletsang kyletsang Apr 25, 2023

Choose a reason for hiding this comment

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

Typo in "Scroll"

jquense reacted with laugh emoji
@kyletsang kyletsang linked an issue Apr 25, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kyletsang kyletsang kyletsang left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Modal: accept role as a prop

AltStyle によって変換されたページ (->オリジナル) /