Skip to content

[LiveComponent] Smooth out parent-child component relationship #113

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

Merged
merged 1 commit into from
Jul 6, 2021

Conversation

weaverryan
Copy link
Member

@weaverryan weaverryan commented Jun 29, 2021

Q A
Bug fix? yes
New feature? yes
Tickets #102 addresses Bug C and Bug F
License MIT

This PR is to address a few outstanding issues related to nested or "parent/child" components:

  • [LiveComponent] Meta issue for todos, changes & bugs #102 Bug C: When a model is updated in a child component, that parent component does not receive that component update (e.g. imagine a form that renders a component... and one field is rendered inside another component - when the child component's model is updated, it should also update that same model in the parent component [the form]).
  • Change data-model to take priority over name so that child components can use data-model and allow parent components to still use the name attribute to match up with their model.
  • Change the new live:update-model event to also (when possible) pass the relevant element so that the listener can look at both the name and data-model attribute to find a match. Or find an alternative solution.
  • Document how parent/child components work (e.g. that when a parent re-renders, the child does not re-render)
  • [LiveComponent] Meta issue for todos, changes & bugs #102 Bug F: Add a way to "force" a child component to re-render
  • Document a known edge case: if a child component re-renders, and the shared model value (shared with a parent component) CHANGES in the AJAX response (e.g. content=foo is sent to the server but content=FOO is returned, and so FOO is now the new value of the content model), a parent will not be aware of this change.
  • Add way to "map" a child model onto a parent model so that you can "map" a private LiveProp from a child onto a parent so that it's not lost if the parent renders over the child.
  • Standardize / cleanup more tests with mockRerender().

@weaverryan
Copy link
Member Author

This is ready to go - the README.md is updated. Mostly, this makes parent-child relationships much smarter to capture the "95%" use-case without any extra config.

Copy link
Member

@kbond kbond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the readme: looks great. The full example is a nice touch!

@weaverryan weaverryan merged commit 13804e6 into symfony:main Jul 6, 2021
weaverryan added a commit that referenced this pull request Jul 7, 2021
…ld changes (weaverryan)

This PR was merged into the main branch.

Discussion
----------

Adding details to LiveComponent changelog about parent-child changes

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Tickets       | none
| License       | MIT

CHANGELOG for #113, which I forgo to include.

Cheers!

Commits
-------

0a6684c Adding details to LiveComponent changelog about parent-child changes
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

Successfully merging this pull request may close these issues.

2 participants