-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat(hooks): add useLayoutState
#99
Conversation
To understand the overall direction we're heading UI-wise first: Layout state (collapsed/expanded) is sticky across elements: Section This PR adds the foundations to ensure that if element |
Exactly! |
Adding @andreasgeier for a design review (proper behavior). Command to try it out npx @bpmn-io/sr bpmn-io/bpmn-properties-panel#main -l bpmn-io/properties-panel#98-keep-group-state -c 'npm run start:platform' |
The root level (sections/groups) works exactly as expected - great work! But we have inconsistency on other levels. For instance, a user creates 3 input variables and some of them are in opened state. If the input group is closed and re-opened without switching the element, the variables keep their state but when switching the element selection, all variables within the input section are closed. @pinussilvestrus Let me know how to proceed here. Having this behavior available on the root is already a great improvement. We can discuss if we want to handle other levels as well (and how) or tackling it in another PR or ignore it for now. |
I think we have a good chance to use the same strategy for other components as well (as sketched for list items in #90 (comment)). I think this PR is a good starting point how to tackle a similar set of problems (persisting component state during a session). If we agree on something (+ merge) we can freely do the same for other parts (as mentioned in #99 (comment)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our discussion that this solution works as expected for groups and the behavior of the sub-levels are considered in another issue, I can approve this.
|
||
const { result } = renderHook(() => useLayoutState(path), { wrapper }); | ||
|
||
const [ , setState ] = result.current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
LGTM |
Really cool stuff. |
Let's roll this out for other components as well as a next step (example: #90). |
Proposal: This adds a
useLayoutState
hook to persist state inside the globalLayoutContext
. TheLayoutContext
can be used to persist state for components that might not be rendered sometimes (example groups), but we want to keep.Potentially it would also be possible to persist this layout state outside of the application (e.g. the Camunda Modeler), via
propertiesPanel.layoutChanged
+ thelayoutConfig
parameter.Closes #98