Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix $persist breaking Alpine when Tabs are used in modals #12191

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

jackwh
Copy link
Contributor

@jackwh jackwh commented Apr 4, 2024

Description

We can persist the currently active Tab to localStorage:

Tabs::make('Example Tabs')
                ->persistTab(true)
                ->id('example-tabs')
                ->tabs([...])

I can see the value being updated and written in devtools when the tab is changed. However, when tabs are used in a modal which is being dismissed, the value of tab is incorrectly set to undefined during a Livewire commit hook.

When opening the modal again, the UI breaks and nothing is rendered. This error appears in the console:

Screenshot 2024-04-04 at 17 08 10@2x

The fix seems to be to fall back to the current tab, instead of trying to persist a potentially undefined array offset.

Visual changes

N/A

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.

@jackwh
Copy link
Contributor Author

jackwh commented Apr 4, 2024

Related Alpine PR: alpinejs/alpine#4128

@zepfietje zepfietje added the bug Something isn't working label Apr 4, 2024
@zepfietje zepfietje added this to the v3 milestone Apr 4, 2024
@thethunderturner
Copy link
Contributor

Hello, I have a similar issue
image
Not sure if they are related but I just have a modal action in my header, and when I press confirm, the action is "loading" and I get this error in the console

@danharrin danharrin merged commit 52854ae into filamentphp:3.x Apr 11, 2024
10 checks passed
@jackwh jackwh deleted the patch-1 branch April 25, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants