Skip to content

Modals: migrate Livewire div modals to native <dialog> + showModal() #87

Open

Description

@johnhringiv

Context

Modals are Livewire-rendered divs: <div class="modal modal-open" role="dialog"> + .modal-box + a .modal-backdrop with wire:click to close:

  • resources/views/components/admin/confirmation-modal.blade.php
  • resources/views/livewire/flash-list.blade.php (edit modal ~L87, delete confirm ~L103)

Missing vs. a real modal: no focus trap (Tab reaches the page behind), page isn't inert for screen readers, no Esc to close, no scroll lock, and z-index: 999 stacking.

Bootstrap 6 replaced Modal with native <dialog> + showModal(), ::backdrop (with backdrop-filter), @starting-style entry, and html.dialog-open scroll lock with scrollbar-gutter: stable.

Proposed

  • Render <dialog class="modal" wire:ignore.self> and open it with a tiny Alpine hook, e.g. x-init="$el.showModal()" when the Livewire condition renders it, or x-effect bound to an entangled $wire.showEditModal.
  • Map native close (Esc / cancel event) back to the Livewire close method: @close="$wire.closeEditModal()".
  • Backdrop click: @click.self on the dialog (the dialog box is the only non-backdrop area if padding lives on an inner element).
  • CSS: .modal::backdrop { background: oklch(0% 0 0deg / 0.4); }; drop .modal-backdrop, .modal-open, z-index: 999; html:has(dialog[open]) { overflow: hidden; scrollbar-gutter: stable; }.
  • Browser tests: existing modal tests should still pass; add one for Esc closing + focus staying inside.

Inspired by the Bootstrap 6 alpha (migration guide) — not adopting Bootstrap, just borrowing the idea.

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions