mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Base: Use native light dismiss for settings dialogs
Rather than rolling our own JavaScript to detect clicks outside of the dialogs and close them we can set the closedby attribute to "any" which will do the same thing. This should also handle platform-specific user actions like pressing the Escape key but this doesn't currently work so keep our JavaScript to handle that and add a FIXME.
This commit is contained in:
Notes:
github-actions[bot]
2026-04-08 01:28:43 +00:00
Author: https://github.com/JRaspass 🔰 Commit: https://github.com/LadybirdBrowser/ladybird/commit/a6293178403 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8808 Reviewed-by: https://github.com/trflynn89 ✅
@@ -574,7 +574,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dialog id="languages-dialog">
|
||||
<dialog id="languages-dialog" closedby="any">
|
||||
<div class="dialog-header">
|
||||
<h3 class="dialog-title">Languages</h3>
|
||||
<button id="languages-close" class="close-button dialog-button">×</button>
|
||||
@@ -591,7 +591,7 @@
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<dialog id="search-dialog">
|
||||
<dialog id="search-dialog" closedby="any">
|
||||
<div class="dialog-header">
|
||||
<h3 class="dialog-title">Search Settings</h3>
|
||||
<button id="search-close" class="close-button dialog-button">×</button>
|
||||
@@ -616,7 +616,7 @@
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<dialog id="site-settings">
|
||||
<dialog id="site-settings" closedby="any">
|
||||
<div class="dialog-header">
|
||||
<h3 id="site-settings-title" class="dialog-title"></h3>
|
||||
<button id="site-settings-close" class="close-button dialog-button">×</button>
|
||||
@@ -639,7 +639,7 @@
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<dialog id="browsing-data-settings-dialog">
|
||||
<dialog id="browsing-data-settings-dialog" closedby="any">
|
||||
<div class="dialog-header">
|
||||
<h3 class="dialog-title">Clear Browsing Data</h3>
|
||||
<button id="browsing-data-settings-close" class="close-button dialog-button">×</button>
|
||||
@@ -722,20 +722,8 @@
|
||||
switchTab(hash);
|
||||
}
|
||||
|
||||
// FIXME: Remove this once closedby="any" triggers for Esc key.
|
||||
document.querySelectorAll("dialog").forEach(dialog => {
|
||||
dialog.addEventListener("click", event => {
|
||||
const rect = dialog.getBoundingClientRect();
|
||||
|
||||
if (
|
||||
event.clientX < rect.left ||
|
||||
event.clientX > rect.right ||
|
||||
event.clientY < rect.top ||
|
||||
event.clientY > rect.bottom
|
||||
) {
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.addEventListener("keydown", event => {
|
||||
if (event.key === "Escape") {
|
||||
dialog.close();
|
||||
|
||||
Reference in New Issue
Block a user