✨(frontend) add keepAlive option to Panel component
Implement new keepAlive property for Panel component to control DOM retention when panel is closed. When false, panel content is unmounted from DOM on close, resetting scroll position and input states. Provides finer control over panel behavior and memory management.
This commit is contained in:
committed by
aleb_the_flash
parent
56c1cd98fa
commit
94171dcb82
@@ -110,9 +110,10 @@ const StyledSidePanel = ({
|
||||
type PanelProps = {
|
||||
isOpen: boolean
|
||||
children: React.ReactNode
|
||||
keepAlive?: boolean
|
||||
}
|
||||
|
||||
const Panel = ({ isOpen, children }: PanelProps) => (
|
||||
const Panel = ({ isOpen, keepAlive = true, children }: PanelProps) => (
|
||||
<div
|
||||
style={{
|
||||
display: isOpen ? 'inherit' : 'none',
|
||||
@@ -121,7 +122,7 @@ const Panel = ({ isOpen, children }: PanelProps) => (
|
||||
flexGrow: 1,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
{keepAlive || isOpen ? children : null}
|
||||
</div>
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user