-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make dialog and drawer more resilient to upcoming CloseWatcher API (#…
…1848) ## 🤨 Rationale There is a change to the HTML spec introducing the `CloseWatcher` API, which affects the way the native `dialog` element behaves. Recently, Chrome had released their implementation, and it broke our drawer and dialog (see issue #1713, as well as resulting [Chromium issue](https://bugs.chromium.org/p/chromium/issues/detail?id=1512224)). Though they rolled back their release of that feature (by moving it back to experimental), it will eventually be implemented in Chrome and other browsers in some form. We want to at least guard against leaving the drawer/dialog in a bad state. Also fixes #1445 ## 👩💻 Implementation The issue is that the `cancel` event is intentionally not fired in a couple cases where the `dialog` is dismissed with ESC. - One such case was when the there is no user interaction (e.g. clicking, scrolling) in the `dialog` before pressing ESC. Apparently, this is [viewed as a mistake and will likely be changed](whatwg/html#10046). - Another case that is [more fundamental to the `CloseWatcher` API](https://github.com/WICG/close-watcher#abuse-analysis) is when there are two ESC presses without an intervening user interaction. I have added a `close` event handler in both the drawer and dialog that resolves and clears the promise, if there is one still set. This ensures we are not left in a bad state where the drawer/dialog can't be reopened. Note there are still problems: - the drawer closes without animation (because we rely on the `cancel` event to trigger the animation) - the drawer/dialog can be closed with ESC even if `prevent-dismiss` is set Depending on the ultimate `CloseWatcher` specification, we may decide to deprecate the `prevent-dismiss` option. OTHER CHANGES: - Gave the dialog proper focus styling, rather than the default. ## 🧪 Testing I added tests for the specific case now being handled, though these won't currently be running against any browser versions that would exhibit the problem behavior. I did manual testing using a [version of Chromium](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/1241130/) with the `CloseWatcher` API enabled. ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
- Loading branch information
Showing
8 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@ni-nimble-components-697d280f-9413-48ef-b2a4-0704abc5584c.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Clean up dialog/drawer properly if cancel event skipped", | ||
"packageName": "@ni/nimble-components", | ||
"email": "7282195+m-akinc@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters