-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Overlay] Enforce focus after backdrop mouse down #1330
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,10 +309,15 @@ export class Overlay extends React.Component<IOverlayProps, IOverlayState> { | |
} | ||
|
||
private handleBackdropMouseDown = (e: React.MouseEvent<HTMLDivElement>) => { | ||
if (this.props.canOutsideClickClose) { | ||
safeInvoke(this.props.onClose, e); | ||
const { backdropProps, canOutsideClickClose, enforceFocus, onClose } = this.props; | ||
if (canOutsideClickClose) { | ||
safeInvoke(onClose, e); | ||
} | ||
if (enforceFocus) { | ||
// make sure document.activeElement is updated before bringing the focus back | ||
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. not sure I understand this comment -- what's the "before" part about? isn't it updating document.activeElement by bringing the focus back? 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. Kind of the same problem than in In both this case and the one from the URL above, 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.
|
||
requestAnimationFrame(() => this.bringFocusInsideOverlay()); | ||
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. why do we need requestAnimationFrame? 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. 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. that link demonstrates 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. We're already using 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. we've enjoyed success using |
||
} | ||
safeInvoke(this.props.backdropProps.onMouseDown, e); | ||
safeInvoke(backdropProps.onMouseDown, e); | ||
} | ||
|
||
private handleDocumentClick = (e: MouseEvent) => { | ||
|
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.
would be super great to add a unit test for this case. we have others for
enforceFocus
, should be a matter of copy-and-edit.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.
Failing so far. What I have:
I can't figure out what the last line should be. As of now, it gives me this:
which I don't understand because the
BACKDROP_SELECTOR
element exists, also why isdocument.activeElement
equals tobody
after mousing down on the backdrop?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.
✅ test fixed