Tab closed when I open url in new tab and change theme
I create a custom theme-switch (copy paste filament theme switch in blade), but when I open my pages in new tab and then switch the theme closed that new tab, what should be the issue?
My theme switch blade
Register in panel providers using render hook
Solution:Jump to solution
I think I found the issue. You can add a
close()
method to the wrapper div:
```
x-data="{
theme: null,
...10 Replies
This happen when I open "any" page in new tab then switch theme, other than theme switch, everything is working fine in new tab
bump 🤥
I don't get it... switching to Dark theme ramdomly closes the active tab?
Can you replicate this with the built-in theme switcher? Or is the issue only with your custom switcher?
Not dark theme only, any theme button.., open any page in new-tab, then switching theme closed that new tab... and yes this only happen in my custom switcher, working fine in built-in.
Is this on Github? Or can you setup a small reproduction repository? I can give it a try if you want.
I am out of work rn, will setup a repo tomorrow and share here.. thank you in advance
Hi @Patrick Boivin here is the reproduction repo https://github.com/valpuia/theme-switch-in-panel Just follow readme file
I'll give this a try today
Solution
I think I found the issue. You can add a
close()
method to the wrapper div:
There's a call to
close()
inside of the theme-switcher.button
component (because it's inside of a dropdown)
And because it doesn't exist in this context, it bubbles up to the window
element and it closes the browser tabThank you very much, it's working..