Repository navigation
DatasetteModal.alert() replaces native alert() calls - #3104
Merged
Merged
Conversation
Browsers embedded in other applications can dismiss a native alert()
without showing it, so the message is never seen.
DatasetteModal.alert({message, okLabel}) shows the message in an
in-page alertdialog with a single button and returns a promise that
resolves when it is dismissed. It shares its implementation with
DatasetteModal.confirm().
The edit tools loader and the API explorer now use it in place of
alert(). Messages in both dialogs keep their line breaks and scroll
when too long to fit.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3104 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 81 81
Lines 14574 14577 +3
=====================================
- Misses 14574 14577 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
simonw
commented
Nov 22, 2026
Comment on lines
+638
to
+647
| The dialog behaves like a native alert for keyboard and screen reader users: | ||
|
|
||
| - It is a modal dialog with the ``alertdialog`` role, labelled by its message, so screen readers announce the message when the dialog opens. | ||
| - The rest of the page cannot be reached with the keyboard or a screen reader while it is open. | ||
| - Keyboard focus moves to the button, so Enter, Space or Escape dismiss the dialog. | ||
| - Focus returns to the element that had it before the dialog opened. | ||
|
|
||
| A message that is too long to fit on the screen scrolls, with the button still visible. | ||
|
|
||
| An alert interrupts the user, so keep it for messages that have no better place. An error that relates to a form field or a dialog that is already open is better shown next to that field or inside that dialog. |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
simonw
added a commit
that referenced
this pull request
Nov 23, 2026
Refs #1048, #1342, #1479, #1553, #1611, #1627, #1630, #1671, #1674, #1822, #1841, #1873, #1914, #1919, #1973, #2045, #2073, #2145, #2253, #2356, #2419, #2713, #2805, #2807, #2810, #2826, #2942, #2967, #3070, #3074, #3075, #3078, #3079, #3081, #3082, #3083, #3084, #3085, #3087, #3088, #3089, #3090, #3091, #3092, #3093, #3097, #3098, #3099, #3100, #3101, #3102, #3103, #3104, #3105, #3106, #3107, #3108, #3109, #3111, #3112, #3113, #3115
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Browsers embedded in other applications can dismiss a native
alert()without showing it, so the user never sees the message. This adds an in-page replacement and uses it for the fivealert()calls Datasette had left.Claude Fable 5.2 High
The method
It takes an options object like
DatasetteModal.confirm()and returns a promise that resolves when the user dismisses the dialog.alert()andconfirm()now share one dialog-building helper inmodal.js.Accessibility compared with native
alert()Matching native behaviour:
alertdialogrole, labelled by its message, so screen readers announce the message when it opens.Better than native:
One difference: it does not pause the calling script, so code that must run after dismissal has to
awaitit. The documentation says so.Changes
datasette/static/modal.js: newDatasetteModal.alert(), sharing a helper withconfirm().datasette/static/edit-tools-loader.js: the "Could not load the editing tools" message uses it.datasette/templates/api_explorer.html: the four JSON and request errors use it.datasette/static/app.css: the shared message style gainswhite-space: pre-wrapand scrolling. This also applies toconfirm()dialogs.docs/javascript_plugins.rst: new "Alert dialogs" section, plus a changelog entry.AGENTS.md: the rule about native dialogs now namesDatasetteModal.alert()as the fallback for errors with no better place in the page.Testing
Four new Playwright tests cover the method itself, an alert on top of another dialog, the edit tools load failure, and the API explorer errors. The Chromium Playwright suite passes locally (184 tests). Firefox and WebKit were not run locally.
🤖 Generated with Claude Code