-
Notifications
You must be signed in to change notification settings - Fork 812
[Fixed issue #464] #540
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
[Fixed issue #464] #540
Conversation
Hi @kloots There are 3 PRs in one. If you can stack 3 commits, one for each fix, it will show up better on the log and changelog. |
Something like this. |
...and thank you for taking a look on this. |
This line also needs a condition ModalPortal.js#L151, otherwise the |
9fe0b63
to
4999fce
Compare
@diasbruno All your suggestions are done, done and done |
4999fce
to
c2f2ef5
Compare
@diasbruno any reason this hasn't been merged yet? Asking because we need this for Slack. |
@kloots @ilikepies101 I'd be in favor of the first PR, just because it was the first...but it seems that the other PR will need to be rebased and also this one is more complete. So, I'll merge this one. Thank you both for working on this issue. |
Released |
// 2. Explicit direction to not restore focus | ||
return ( | ||
this.props.shouldFocusAfterRender || | ||
this.props.shouldReturnFocusAfterClose |
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.
I believe this should be &&
not ||
. Currently I have to pass both shouldFocusAfterRender={false}
and shouldReturnFocusAfterClose={false}
to opt out of refocusing.
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.
Looking at this now, if shouldReturnFocusAfterClose=false
, it would also disable the 'focus after render'. They must be independent.
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.
NOTES:
If shouldFocusAfterRender=true and shouldReturnFocusAfterClose=false
, we put the element in the focus manager and on close we just pop it out.
shouldFocusAfterRender=false and shouldReturnFocusAfterClose=true
must be noop just like shouldFocusAfterRender=false and shouldReturnFocusAfterClose=false
.
shouldFocusAfterRender=true and shouldReturnFocusAfterClose=true
is the default behavior.
Does this make sense?
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.
Yeah, sounds reasonable
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.
Btw, what are the usecases for shouldFocusAfterRender
? Looks like it just focuses a div without any keyboard handlers
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.
To set the scope for tabbing, so it won't leave the modal when it's open.
Fixes #464.
Changes proposed:
shouldReturnFocusAfterClose
allowing explicit control over if a modal should restore focus to the element that had focus prior to its displayed.shouldFocusAfterRender
was set tofalse
)Modal
props so thatshouldFocusAfter
is now correctlyshouldFocusAfterRender
Acceptance Checklist:
CONTRIBUTING.md
.