Skip to content

Overlay stops working as it does not append "hidden" class with DOM replacement #704

@makikata

Description

@makikata

Summary

On a turbo:load event, I use autoInit() but then overlay does not close anymore

Steps to Reproduce

This is how I found the bug, but I think it can be reproduced with simpe JS.

  1. Using Turbo with Ruby on Rails but I think this is irrelevant. We just need to replace the DOM
  2. Turbo replaces the HTML body of the page with the response body. Another DOM is then in place.
  3. There is an event listener on turbo:load that re-initiate the components using window.HSStaticMethods.autoInit(). Or we can just usewindow.HSOverlay.autoInit(), it will be the same result
  4. When clicking on the toggle button, the sidebar does not get "hidden" class as shown in the video
bug.mov

Please read the README.md for instructions and investigation

Thank you! ❤️

Demo Link

https://codesandbox.io/p/github/makikata/demo-preline/main

Expected Behavior

When I click on the toggle button it should hide the sidebar, the "hidden" class should be added to the sidebar

Actual Behavior

When I click on the toggle button does not hide the sidebar, the "hidden" class is not added to the sidebar

Screenshots

bug.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions