Replace Modal.isOpen with controlled boolean #422
Merged
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.
Overview
When writing the Modal component for prime-core, I suggested we ditch events in favor of the two-way data binding of an
isOpen
store. After some usage in the app, we've discovered this is a pretty awkward API.This PR switches the modal back to a plain, controlled
isOpen: boolean
prop and aclose
event, which should be more predictable. As a result, this means the modal is no longer capable of closing itself; it must emit theclose
event and the parent must chose to close it.I think there are continuing improvements to be made here, especially given the awkwardness of combining the
close
event with any buttons placed in theprimary
andsecondary
slots, but I think this is a step in the right direction.This is a breaking change to prime-core. See the companion PR in the app: https://github.com/viamrobotics/app/pull/2873
Review requests