diff --git a/docs/content/docs/2.components/context-menu.md b/docs/content/docs/2.components/context-menu.md index 2183fe06ac..87f2ed1659 100644 --- a/docs/content/docs/2.components/context-menu.md +++ b/docs/content/docs/2.components/context-menu.md @@ -298,6 +298,43 @@ slots: :div{class="flex items-center justify-center rounded-md border border-dashed border-accented text-sm aspect-video w-72"}[Right click here] :: +### Unmount :badge{label="Soon" class="align-text-top"} + +Use the `unmount-on-hide` prop to prevent the ContextMenu's content and its sub menus from being unmounted when it is closed. Defaults to `true`. + +::component-code +--- +prettier: true +collapse: true +ignore: + - items + - ui.content +external: + - items +externalTypes: + - ContextMenuItem[] +props: + unmountOnHide: false + items: + - label: System + icon: i-lucide-monitor + - label: Light + icon: i-lucide-sun + - label: Dark + icon: i-lucide-moon + ui: + content: 'w-48' +slots: + default: | + +
+ Right click here +
+--- + +:div{class="flex items-center justify-center rounded-md border border-dashed border-accented text-sm aspect-video w-72"}[Right click here] +:: + ## Examples ### With checkbox items diff --git a/docs/content/docs/2.components/dropdown-menu.md b/docs/content/docs/2.components/dropdown-menu.md index c084bb37a0..60a5e2650f 100644 --- a/docs/content/docs/2.components/dropdown-menu.md +++ b/docs/content/docs/2.components/dropdown-menu.md @@ -501,6 +501,41 @@ slots: :u-button{label="Open" icon="i-lucide-menu" color="neutral" variant="outline"} :: +### Unmount :badge{label="Soon" class="align-text-top"} + +Use the `unmount-on-hide` prop to prevent the DropdownMenu's content and its sub menus from being unmounted when it is closed. Defaults to `true`. + +::component-code +--- +prettier: true +collapse: true +ignore: + - items + - ui.content +external: + - items +externalTypes: + - DropdownMenuItem[] +props: + unmountOnHide: false + items: + - label: Profile + icon: i-lucide-user + - label: Billing + icon: i-lucide-credit-card + - label: Settings + icon: i-lucide-cog + ui: + content: 'w-48' +slots: + default: | + + +--- + +:u-button{label="Open" icon="i-lucide-menu" color="neutral" variant="outline"} +:: + ## Examples ### With checkbox items diff --git a/docs/content/docs/2.components/input-menu.md b/docs/content/docs/2.components/input-menu.md index fbe30b87d7..d0c3c7a3d8 100644 --- a/docs/content/docs/2.components/input-menu.md +++ b/docs/content/docs/2.components/input-menu.md @@ -343,6 +343,35 @@ props: --- :: +### Unmount :badge{label="Soon" class="align-text-top"} + +Use the `unmount-on-hide` prop to prevent the content from being unmounted when the InputMenu is closed. Defaults to `true`. + +::component-code +--- +prettier: true +ignore: + - items + - modelValue + - unmountOnHide +external: + - items + - modelValue +props: + modelValue: 'Backlog' + unmountOnHide: false + items: + - Backlog + - Todo + - In Progress + - Done +--- +:: + +::note +This prop has no effect when `mode` is set to `autocomplete`. +:: + ### Color Use the `color` prop to change the ring color when the InputMenu is focused. diff --git a/docs/content/docs/2.components/popover.md b/docs/content/docs/2.components/popover.md index a31d326086..c2f17efcf3 100644 --- a/docs/content/docs/2.components/popover.md +++ b/docs/content/docs/2.components/popover.md @@ -214,6 +214,37 @@ name: 'popover-dismissible-example' --- :: +### Unmount :badge{label="Soon" class="align-text-top"} + +Use the `unmount-on-hide` prop to prevent the Popover's content from being unmounted when it is closed. Defaults to `true`. + +::component-code +--- +prettier: true +ignore: + - title +props: + unmountOnHide: false +slots: + default: | + + + + content: | + + +--- + +:u-button{label="Open" color="neutral" variant="subtle"} + +#content +:placeholder{class="size-48 m-4 inline-flex"} +:: + +::note +This prop only applies to the `click` mode. The `hover` mode uses the Reka UI `HoverCard` which has no such option. +:: + ## Examples ### Control open state diff --git a/docs/content/docs/2.components/select-menu.md b/docs/content/docs/2.components/select-menu.md index 2d5b97d786..69f86937ac 100644 --- a/docs/content/docs/2.components/select-menu.md +++ b/docs/content/docs/2.components/select-menu.md @@ -353,6 +353,33 @@ props: --- :: +### Unmount :badge{label="Soon" class="align-text-top"} + +Use the `unmount-on-hide` prop to prevent the content from being unmounted when the SelectMenu is closed. Defaults to `true`. + +::component-code +--- +prettier: true +ignore: + - items + - modelValue + - class + - unmountOnHide +external: + - items + - modelValue +props: + modelValue: 'Backlog' + unmountOnHide: false + items: + - Backlog + - Todo + - In Progress + - Done + class: 'w-48' +--- +:: + ### Color Use the `color` prop to change the ring color when the SelectMenu is focused. diff --git a/src/runtime/components/ContextMenu.vue b/src/runtime/components/ContextMenu.vue index 6bc6d0dad5..7af985e179 100644 --- a/src/runtime/components/ContextMenu.vue +++ b/src/runtime/components/ContextMenu.vue @@ -43,7 +43,7 @@ export interface ContextMenuItem extends Omit = ArrayOrNested> extends Omit { +export interface ContextMenuProps = ArrayOrNested> extends Omit { /** * @defaultValue 'md' */ @@ -127,7 +127,8 @@ const _props = withDefaults(defineProps>(), { modal: true, externalIcon: true, labelKey: 'label', - descriptionKey: 'description' + descriptionKey: 'description', + unmountOnHide: true }) const emits = defineEmits() const slots = defineSlots>() @@ -136,7 +137,7 @@ const props = useComponentProps>('contextMenu', _props) const appConfig = useAppConfig() as ContextMenu['AppConfig'] -const rootProps = useForwardProps(props, ['open', 'pressOpenDelay', 'modal'], emits) +const rootProps = useForwardProps(props, ['open', 'pressOpenDelay', 'modal', 'unmountOnHide'], emits) const contentProps = toRef(() => props.content) const getProxySlots = () => omit(slots, ['default']) diff --git a/src/runtime/components/DropdownMenu.vue b/src/runtime/components/DropdownMenu.vue index a0ac499588..8a9eb0d636 100644 --- a/src/runtime/components/DropdownMenu.vue +++ b/src/runtime/components/DropdownMenu.vue @@ -47,7 +47,7 @@ export interface DropdownMenuItem extends Omit = ArrayOrNested> extends Omit { +export interface DropdownMenuProps = ArrayOrNested> extends Omit { /** * @defaultValue 'md' */ @@ -161,7 +161,8 @@ const _props = withDefaults(defineProps>(), { labelKey: 'label', descriptionKey: 'description', filter: false, - ignoreFilter: false + ignoreFilter: false, + unmountOnHide: true }) const emits = defineEmits() const slots = defineSlots>() @@ -172,7 +173,7 @@ const props = useComponentProps>('dropdownMenu', _props) const appConfig = useAppConfig() as DropdownMenu['AppConfig'] -const rootProps = useForwardProps(props, ['defaultOpen', 'open', 'modal'], emits) +const rootProps = useForwardProps(props, ['defaultOpen', 'open', 'modal', 'unmountOnHide'], emits) const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8 }) as DropdownMenuContentProps) const arrowProps = toRef(() => defu(props.arrow, { rounded: true }) as DropdownMenuArrowProps) const getProxySlots = () => omit(slots, ['default']) diff --git a/src/runtime/components/DropdownMenuContent.vue b/src/runtime/components/DropdownMenuContent.vue index 836e83d180..aec114a0c9 100644 --- a/src/runtime/components/DropdownMenuContent.vue +++ b/src/runtime/components/DropdownMenuContent.vue @@ -58,9 +58,9 @@ type DropdownMenuContentSlots<