Closed alissa-tung closed 7 months ago
Can I use conditional rendering with imperative group panel API?
No. The concept of conditional rendering is that sometimes you render a panel, and sometimes you don't. In order to use the imperative API, the panel must be rendered (even if it's collapsed).
but just not use conditional render {?:}, instead of set the panel size to zero (without filtering the list) makes the layout seems normal, except there is a 0 width panel and 1 width panel handle.
Yes. I suggest you just conditionally render them. There isn't really enough info in this issue for me to understand why that isn't sufficient.
I don't know anything about the shad UI library you're using, but if you can share a Code Sandbox showing what you're trying to do, I will take a look. I'll need to see complete code example though.
Can I use conditional rendering with imperative group panel API?
No. The concept of conditional rendering is that sometimes you render a panel, and sometimes you don't. In order to use the imperative API, the panel must be rendered (even if it's collapsed).
but just not use conditional render {?:}, instead of set the panel size to zero (without filtering the list) makes the layout seems normal, except there is a 0 width panel and 1 width panel handle.
Yes. I suggest you just conditionally render them. There isn't really enough info in this issue for me to understand why that isn't sufficient.
I don't know anything about the shad UI library you're using, but if you can share a Code Sandbox showing what you're trying to do, I will take a look. I'll need to see complete code example though.
Thank you for hints on collapsed
, I had rewrite my code to using collapsed
and expand
, then everything works fine.
And my question is got answered by In order to use the imperative API, the panel must be rendered (even if it's collapsed).
So I will close this as completed.
In addition, I am using a version wrapped by https://ui.shadcn.com/ , and I had add the https://github.com/shadcn-ui/ui/pull/2699 support
updated: i had tested on the raw version of this library, still not work too
here the terms conditional rendering refers to https://react-resizable-panels.vercel.app/examples/conditional , and imperative group panel API refers to https://react-resizable-panels.vercel.app/examples/imperative-panel-group-api .
I had done a lot of test, when using something like
and the
setLayout
is fromthe layout does not respect to the value of
getLayout()
aftersetLayout
.but just not use conditional render
{?:}
, instead of set the panel size to zero (without filtering the list) makes the layout seems normal, except there is a 0 width panel and 1 width panel handle.