[Modal] Option to make restoring focus, after a modal hides ,optional #433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Before a modal is shown, it saves the current focussed element and restores it, after the modal was hidden again.
In some cases this might be unwanted behavior, like in Semantic-Org/Semantic-UI#6198 , where i also adopted the Testcase, so i made refocus now optional by implementing a new option
restoreFocus
(default true to keep current behavior)Testcase
https://jsfiddle.net/3nmLycdr/
This was taken and adjusted from the original PR
cancel
, so it closes againWhen
restoreFocus: true
(behavior as before), the viewport now autoscrolls up to where the buttons areWhen
restoreFocus: false
(set in the fiddle), the viewport stays where it isThe original PR was also forcing the code to have the element being visible to make it scroll. I don't think this should be forced, so i decided just to go with the additional setting... which exactly fixes, what the issue was originally made for.
Closes
Semantic-Org/Semantic-UI#6198