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

[@mantine/core] Tabs: Add keepMounted prop to TabsPanel #5283

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/mantine-core/src/components/Tabs/TabsPanel/TabsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export interface TabsPanelProps
ElementProps<'div'> {
/** Panel content */
children: React.ReactNode;

/** If set to `true`, the content will be kept mounted, even if `keepMounted` is set `false` in the parent `Tabs` component */
keepMounted?: boolean;
/** Value of associated control */
value: string;
}
Expand All @@ -40,7 +41,7 @@ export const TabsPanel = factory<TabsPanelFactory>((_props, ref) => {
const ctx = useTabsContext();

const active = ctx.value === value;
const content = ctx.keepMounted ? children : active ? children : null;
const content = ctx.keepMounted || props.keepMounted ? children : active ? children : null;

return (
<Box
Expand Down