Skip to content
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] ThemedSiderV2 Persist Collapsed State #6508

Closed
aress31 opened this issue Nov 19, 2024 · 10 comments · Fixed by #6527, #6518 or #6577
Closed

[FEAT] ThemedSiderV2 Persist Collapsed State #6508

aress31 opened this issue Nov 19, 2024 · 10 comments · Fixed by #6527, #6518 or #6577
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers up for grabs

Comments

@aress31
Copy link

aress31 commented Nov 19, 2024

Is your feature request related to a problem? Please describe.

Would be nice to persist out of the box the collapsed state, or add an option to do so, maybe a "peristCollapsed" boolean. This would avoid having to write extra code for this important UX feature.

Describe alternatives you've considered

No response

Additional context

No response

Describe the thing to improve

See above.

@aress31 aress31 added the enhancement New feature or request label Nov 19, 2024
@BatuhanW BatuhanW self-assigned this Nov 20, 2024
@BatuhanW
Copy link
Member

@aress31 thanks for the issue. We've discussed this one and decided to accept onSiderCollapsed function to ThemedLayoutV2 component.

Then onSiderCollapsed will be passed to ThemedLayoutContextProvider

Here, we should replace existing setSiderCollapsed with a wrapper, where we call setSiderCollapsed state action and also onSiderCollapsed coming from user.

Here is a pseudo implementation:
Screenshot 2024-11-20 at 14 16 42

This will allow users to persist their collapsed state into localstorage in onSiderCollapsed method. And then users can read this from localStorage and pass initial value initialSiderCollapsed from here.

We need to do these changes in ThemedLayoutV2 component for

  • Ant Design
  • Material UI
  • Mantine
  • Chakra UI

They all have almost exact same code, so it should be straightforward to implement.

We are open to contributions for this one.

@wannabecsguy2
Copy link

Hey @BatuhanW, can I work on this?

@OmkarBansod02
Copy link
Contributor

Hey @BatuhanW, I am up for this.

@BatuhanW
Copy link
Member

@wannabecsguy2 Assigning issue to you since you were first to ask 🚀

@OmkarBansod02 If we don't hear back from @wannabecsguy2 you can take this next. We also have other issues that you may want to work on, you can check up for grabs labelled issues ❤️

@OmkarBansod02
Copy link
Contributor

hey @BatuhanW it's been a while. can you assign me this issue so i can make PR .

@OmkarBansod02
Copy link
Contributor

hey @BatuhanW I'm getting a TypeScript error: Property onSiderCollapsed does not exist on type RefineThemedLayoutV2Props. while implementing it in ThemedLayoutV2 Even though I've declared onSiderCollapsed?: (collapsed: boolean) => void; in the RefineThemedLayoutV2Props interface, the error still persists.

@BatuhanW
Copy link
Member

@OmkarBansod02 assigned issue to you. It seems like it should work, you can restart TS server.

@OmkarBansod02
Copy link
Contributor

@BatuhanW, Still getting same error even after restarting TS server. i am adding code snippets below kindly check am i on right path .

  1. File : E:\Refinedev\refine\packages\ui-types\src\types\layout.tsx

Screenshot 2024-11-26 184645

  1. File: E:\Refinedev\refine\packages\mui\src\components\themedLayoutV2\index.tsx (in which getting Error )

Screenshot 2024-11-26 184722

@BatuhanW
Copy link
Member

BatuhanW commented Nov 26, 2024

@OmkarBansod02 ui-types is a separate package. So you need to build it for other packages to see its types.

You can run pnpm build --scope @refinedev/ui-types

@OmkarBansod02
Copy link
Contributor

Thanks for help @BatuhanW , I have made a PR kindly review it and let me know for any improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment