Add declarative data-modal-cancel attribute to datasette-modal

Clicking any element inside a <datasette-modal> that carries a
data-modal-cancel attribute now calls requestClose("cancel"), so
Cancel buttons no longer need JavaScript wiring. Like other
dismissals this respects the busy property and the closeGuard hook.

The set-column-type, row-delete and create-table dialogs now use the
attribute instead of their own click listeners, and the plugin
documentation example is simplified to match (the regenerated docs
screenshot is unchanged).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TShiUYVMmmF4zyJR6GMw34
This commit is contained in:
Claude 2026-07-02 17:25:19 +00:00
commit 32be92fa24
No known key found for this signature in database
6 changed files with 27 additions and 25 deletions

View file

@ -975,6 +975,13 @@ def test_set_column_type_dialog(page, datasette_server):
option_names = dialog.locator(".set-column-type-option-name").all_inner_texts()
assert "asset" in option_names
# Escape closes the dialog via the shared datasette-modal component
# The declarative data-modal-cancel attribute closes the dialog
dialog.locator("[data-modal-cancel]").click()
dialog.wait_for(state="hidden")
# Escape also closes the dialog via the shared datasette-modal component
page.locator('th[data-column="title"] svg.dropdown-menu-icon').click()
page.get_by_role("link", name="Set custom type").click()
dialog.wait_for(state="visible")
page.keyboard.press("Escape")
dialog.wait_for(state="hidden")