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

CSS Tabs loose state when page is live-updated #721

Open
AndrewDryga opened this issue Nov 16, 2023 · 3 comments
Open

CSS Tabs loose state when page is live-updated #721

AndrewDryga opened this issue Nov 16, 2023 · 3 comments

Comments

@AndrewDryga
Copy link

Describe the bug
We are using Phoenix LiveView and when the page is updated tabs loose the state.
Please see firezone/firezone#2657 for the video.

Expected behavior
There should be no compatibility issued with LiveView, Rails StimulusReflex, etc.

Desktop (please complete the following information):

  • OS: MacOS 12.6.5
  • Browser: Chrome
  • Version: 119.0.6045.123
@unematiii
Copy link

You should toggle classes such as hidden for tab content; and aria-selected attribute together with tab styling using Phoenix JS commands, which are patch aware.

@AndrewDryga
Copy link
Author

The issue is not that tabs don't work but that on each update the user is reset to the first tab. We had to write some ugly hacks to save the state of tabs in the LiveView socket to control which tab is open.

@unematiii
Copy link

unematiii commented Jun 4, 2024

That exactly what I'm saying, classes that FlowbiteJS has applied to elements are removed when DOM patch (update) occurs, resetting the tabs back to its initial state. This applies to all sorts of components that rely on Flowbite JavasScript functionality: modals, drawers etc. The best I've come up so far is to apply those classes using https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.JS.html and not rely on init attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants