feat(accessibility): add support for escape key handling #601
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.
Resolves #512.
This PR aims to add escape key handling support for modal instances by having a global handler which programmatically closes last-most instance when the escape key is pressed.
Instead of registering a handler per instance, a global handler is registered once via JavaScript and bypasses using event handlers.
Although I am not the biggest fan of JS, I see no other way for this use-case to be solved. This solution should also mitigate any weird and inconsistent behaviours that occurred with the previous fix caused by #201 and #202.
Additionally, support for disabling escape key handling can be set globally, or per-instance.
I have extended the unit tests to ensure coverage of the newly added feature.
@chrissainty If possible, a review and potential merge would be optimal - as we use this dependency in the customer's project extensively and its requirement is better accessibility. I was assigned to implement this feature, with additional colleague tasked to do a review of my changes - as they do not wish to resort to having to compile a fork.