Skip to content

modal click through allowed#19783

Merged
danharrin merged 30 commits into
filamentphp:4.xfrom
tanthammar:modal-click-through
Jul 8, 2026
Merged

modal click through allowed#19783
danharrin merged 30 commits into
filamentphp:4.xfrom
tanthammar:modal-click-through

Conversation

@tanthammar

@tanthammar tanthammar commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Description

Adds:

  • modalClickThrough(bool $condition = true) to the ModalComponent
  • modalClickThrough(bool | Closure | null $condition = true) to Concerns\CanOpenModal

When enabled, the modal backdrop becomes fully transparent to pointer events and the focus trap is removed, allowing users to interact with content behind the modal while it remains open.

Intended use case
Text only modals/slide-overs that stay open while the user can interact with the page behind/next to the modal.
(Example, show a narrow slide over with help documentation while the user fills out a form.)

Accessibility
By removing x-trap, tab order may be a concern if used with modals containing a form. Suggesting to add a note to documentation.

Visual changes

  • The backdrop overlay is invisible (no dark/dimmed background)
  • The modal window itself remains visible when clicking outside
  • The backdrop area is fully transparent and click-through to content behind

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

Copilot AI and others added 2 commits April 28, 2026 13:51
…entphp#2)

* Add modal close button parent cancellation

Agent-Logs-Url: https://github.com/CamKemBell/filament/sessions/b42b9ac0-2da9-426b-ba8a-1dc091249aaa

Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>

* Polish modal close button cancellation

Agent-Logs-Url: https://github.com/CamKemBell/filament/sessions/b42b9ac0-2da9-426b-ba8a-1dc091249aaa

Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>

* revert: back to original code

* refactor: support for conditional cancellation of parent actions on modal close

* refactor: rename modal close button unmount action methods for clarity

* refactor: simplify modal close button event handler logic

* refactor: simplify modal close button event handler logic

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>
Co-authored-by: Cam Kemshal-Bell <cam@foremind.com.au>
@tanthammar

tanthammar commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

@danharrin

do you want to keep the backdrop and the extra attribute bag?

packages/support/resources/views/components/modal/index.blade.php, line 135

keep backdrop

    <div
            aria-hidden="true"
            x-show="isOpen"
            @unless($isClickThrough)
                x-transition.duration.300ms.opacity
            @endunless
            {{
                ($extraModalOverlayAttributeBag ?? new \Illuminate\View\ComponentAttributeBag)->class([
                    'fi-modal-close-overlay' => ! $isClickThrough,
                    'pointer-events-none' => $isClickThrough,
                ])
            }}
    ></div>

remove backdrop (current)

    @unless($isClickThrough)
        <div
                aria-hidden="true"
                x-show="isOpen"
                x-transition.duration.300ms.opacity
                {{
                    ($extraModalOverlayAttributeBag ?? new \Illuminate\View\ComponentAttributeBag)->class([
                        'fi-modal-close-overlay',
                    ])
                }}
        ></div>
    @endunless

@tanthammar

Copy link
Copy Markdown
Contributor Author

@danharrin

If we want to prevent accessibility issues we could override the feature if the modal contains a form:

// packages/support/resources/views/components/modal/index.blade.php, line 65
$isClickThrough = $clickThrough && !$closeByClickingAway && blank($wireSubmitHandler);

Please tell me if you want that change...

@webard

webard commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Awesome! That's exactly what I needed and I'm working on until now.

@danharrin danharrin added enhancement New feature or request pending review labels Apr 29, 2026
@danharrin danharrin added this to the v4 milestone Apr 29, 2026
CamKemBell and others added 18 commits May 1, 2026 23:55
* Add modal dismissal parent action API

Agent-Logs-Url: https://github.com/CamKemBell/filament/sessions/53b18b70-43ab-41f7-9798-48fd987b9baf

Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>

* Refine modal dismissal API readability

Agent-Logs-Url: https://github.com/CamKemBell/filament/sessions/53b18b70-43ab-41f7-9798-48fd987b9baf

Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>

* Fix modal dismissal flag handling

Agent-Logs-Url: https://github.com/CamKemBell/filament/sessions/53b18b70-43ab-41f7-9798-48fd987b9baf

Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>

* core: remove modalCloseButton method

* core: remove deprecate tests

* docs: update modal documentation to reflect deprecation of modalCloseButton

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: CamKemBell <217516035+CamKemBell@users.noreply.github.com>
Co-authored-by: Cam Kemshal-Bell <cam@foremind.com.au>
@tanthammar tanthammar force-pushed the modal-click-through branch from d8520e1 to a0dcc15 Compare July 3, 2026 14:21
@danharrin danharrin merged commit c88af36 into filamentphp:4.x Jul 8, 2026
23 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Roadmap Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants