This has already been partly answered here: Recommended way to open a LiveComponent Modal *from* another LiveComponent?
However, I find the comments after the solution to be interesting, as I sit with the exact same problem now, and im wondering how to solve this “the Phoenix LiveView way”.
It seems pretty clear cut, and it was also my gut feeling, that the liveview should handle navigation.
However when you have some advanced views, with loads of components on screen, the liveview gets really cluttered.
My example is that I have a header with some information, and a tabbed view.
Each tab does Crud on different data types. The create and edit, prompts a modal for inputting data, before saving.
What is the correct way to compose something like this? How would you divide responsibilities?
Currently the “component” is self contained, and displays the modals, and handles the data updating.
That feels anti pattern, based on the above thread.
What is the correct way then? Passing button presses to the liveview, to display the modal, handle all data updating in the modal, and when it closes, update the component?
I feel like this very quickly ends up with having the liveview manage state for all child components? (Or am I just overthinking that?)
Could the component the a Child liveview instead? Or should It still then only be the parent live views responsibility?
I Could also have multiple live views, each implementing the “header” and “tab” component, and just displaying their “version of it” and its own content below. And then the tab bar handles navigating between the live views. (Feels really clunky, and not intuitive when looking at the screen, but would work I guess)
Any comments, or resources that describe how to work with the problems above?