Clarifications about nested live views and their appropriate use#3713
Merged
SteffenDE merged 4 commits intophoenixframework:mainfrom Mar 13, 2025
Merged
Clarifications about nested live views and their appropriate use#3713SteffenDE merged 4 commits intophoenixframework:mainfrom
SteffenDE merged 4 commits intophoenixframework:mainfrom
Conversation
SteffenDE
approved these changes
Mar 13, 2025
SteffenDE
reviewed
Mar 13, 2025
Collaborator
|
Thank you! 🙌🏻 |
SteffenDE
added a commit
that referenced
this pull request
Mar 20, 2025
* Add hint about find_live_child/2 to the live_render docs. * Add a recommendation to try LiveComponent before resorting to a liveview. * Apply suggestions from code review * Update lib/phoenix_component.ex --------- Co-authored-by: Steffen Deusch <steffen@deusch.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I had a problem with nested live view testing where the test helpers did not understand where to send the click events.
This was discussed in issue #3393 and a subsequent read of the code makes it clear to me that there is no obvious way to have the test infrastructure walk up the DOM or process tree looking for the correct child to send clicks to (if someone knows a way to fix that I would love to encourage you to look into it).
So barring that, and informed by a separate conversation in the forums, here are some bits of advice gleaned from those two conversations. I think if the core Phoenix crew believes that Nested LiveViews are something you should use very sparingly, then the docs should warn new users that they are flying into the proverbial terrain.
There are some old SO threads and ancient forum threads that the participants didn't know about attach_hook. I don't know if that's lack of experience or later additions to the API. I'm hoping some more links in the docs will help with those.