-
Notifications
You must be signed in to change notification settings - Fork 52
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
fix(app): retains group toggle open status #790
Conversation
🦋 Changeset detectedLatest commit: c9534f0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/app/src/hooks/endpoint.ts
Outdated
const [endpointGroups, setEndpointGroups] = useEndpointGroupToggleState(); | ||
|
||
const endpointGroup = endpointGroups.find((group) => group.id === id); | ||
const isOpenToggle = endpointGroup |
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.
Perhaps using optional chaining will improve readability, instead of using the ternary operator.
packages/app/src/hooks/endpoint.ts
Outdated
|
||
return groups.map((group, i) => | ||
i === index | ||
? { ...group, isOpenToggle: group.isOpenToggle !== true } |
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.
Perhaps just using "!" operator would be sufficient to evaluate it.
isOpenToggle: !group.isOpenToggle
packages/app/src/hooks/endpoint.ts
Outdated
const isOpenToggle = | ||
endpointGroups.find((group) => group.id === id)?.isOpenToggle ?? false; | ||
|
||
const setIsOpenToggle = () => { |
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.
Functions that start with "set" are typically considered as setters for private properties. Nonetheless, the absence of arguments in such a function could make its behavior unpredictable.
packages/app/src/store/index.ts
Outdated
@@ -102,3 +102,6 @@ export const useEndpointGroupListItemGlobalStateValue = ( | |||
export const useEndpointGroupListItemGlobalStateSet = ( | |||
params: Parameters<typeof endpointGroupListItemSelector>[0] | |||
) => useGlobalStateSet(endpointGroupListItemSelector(params)); | |||
|
|||
export const useEndpointGroupToggleState = () => |
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.
Could you change this to useEndpointGroupListGlobalState?
Summary
It is now possible to maintain the open/closed state of group toggles using local storage.
Checklist