akar 2.0.4 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/Combobox/ComboboxInput.cjs +6 -1
  2. package/dist/Combobox/ComboboxInput.cjs.map +1 -1
  3. package/dist/Combobox/ComboboxInput.js +6 -1
  4. package/dist/Combobox/ComboboxInput.js.map +1 -1
  5. package/dist/Dialog/DialogOverlayImpl.cjs +6 -1
  6. package/dist/Dialog/DialogOverlayImpl.cjs.map +1 -1
  7. package/dist/Dialog/DialogOverlayImpl.js +7 -2
  8. package/dist/Dialog/DialogOverlayImpl.js.map +1 -1
  9. package/dist/FocusScope/FocusScope.cjs +2 -0
  10. package/dist/FocusScope/FocusScope.cjs.map +1 -1
  11. package/dist/FocusScope/FocusScope.js +2 -0
  12. package/dist/FocusScope/FocusScope.js.map +1 -1
  13. package/dist/Listbox/ListboxItem.cjs +7 -2
  14. package/dist/Listbox/ListboxItem.cjs.map +1 -1
  15. package/dist/Listbox/ListboxItem.js +7 -2
  16. package/dist/Listbox/ListboxItem.js.map +1 -1
  17. package/dist/Menu/MenuItemImpl.cjs +1 -1
  18. package/dist/Menu/MenuItemImpl.cjs.map +1 -1
  19. package/dist/Menu/MenuItemImpl.js +1 -1
  20. package/dist/Menu/MenuItemImpl.js.map +1 -1
  21. package/dist/NavigationMenu/NavigationMenuContentImpl.cjs +1 -0
  22. package/dist/NavigationMenu/NavigationMenuContentImpl.cjs.map +1 -1
  23. package/dist/NavigationMenu/NavigationMenuContentImpl.js +1 -0
  24. package/dist/NavigationMenu/NavigationMenuContentImpl.js.map +1 -1
  25. package/dist/NavigationMenu/NavigationMenuRoot.cjs +16 -3
  26. package/dist/NavigationMenu/NavigationMenuRoot.cjs.map +1 -1
  27. package/dist/NavigationMenu/NavigationMenuRoot.js +16 -3
  28. package/dist/NavigationMenu/NavigationMenuRoot.js.map +1 -1
  29. package/dist/ScrollArea/ScrollAreaScrollbarX.cjs +3 -0
  30. package/dist/ScrollArea/ScrollAreaScrollbarX.cjs.map +1 -1
  31. package/dist/ScrollArea/ScrollAreaScrollbarX.js +4 -1
  32. package/dist/ScrollArea/ScrollAreaScrollbarX.js.map +1 -1
  33. package/dist/ScrollArea/ScrollAreaScrollbarY.cjs +3 -0
  34. package/dist/ScrollArea/ScrollAreaScrollbarY.cjs.map +1 -1
  35. package/dist/ScrollArea/ScrollAreaScrollbarY.js +4 -1
  36. package/dist/ScrollArea/ScrollAreaScrollbarY.js.map +1 -1
  37. package/dist/Select/SelectContent.cjs +13 -2
  38. package/dist/Select/SelectContent.cjs.map +1 -1
  39. package/dist/Select/SelectContent.js +14 -3
  40. package/dist/Select/SelectContent.js.map +1 -1
  41. package/dist/constant.d.cts.map +1 -1
  42. package/dist/constant.d.ts.map +1 -1
  43. package/dist/index2.d.cts.map +1 -1
  44. package/dist/index3.d.cts +15 -15
  45. package/dist/index3.d.cts.map +1 -1
  46. package/dist/index3.d.ts +11 -11
  47. package/dist/index4.d.cts +651 -651
  48. package/dist/index4.d.cts.map +1 -1
  49. package/dist/index4.d.ts +649 -649
  50. package/dist/index4.d.ts.map +1 -1
  51. package/dist/internal.d.cts +2 -2
  52. package/dist/internal.d.cts.map +1 -1
  53. package/dist/internal.d.ts +2 -2
  54. package/package.json +3 -3
  55. package/src/Calendar/CalendarRoot.vue +1 -1
  56. package/src/Combobox/ComboboxInput.vue +14 -1
  57. package/src/DateRangeField/DateRangeFieldRoot.vue +1 -1
  58. package/src/Dialog/DialogOverlayImpl.vue +1 -0
  59. package/src/FocusScope/FocusScope.vue +6 -0
  60. package/src/Listbox/ListboxItem.vue +2 -2
  61. package/src/Menu/MenuItemImpl.vue +1 -1
  62. package/src/MonthPicker/MonthPickerRoot.vue +1 -1
  63. package/src/NavigationMenu/NavigationMenuContentImpl.vue +4 -0
  64. package/src/NavigationMenu/NavigationMenuRoot.vue +21 -4
  65. package/src/NavigationMenu/__test__/NavigationMenuUnmountOnHideFalse.vue +45 -0
  66. package/src/ScrollArea/ScrollAreaScrollbarX.vue +8 -1
  67. package/src/ScrollArea/ScrollAreaScrollbarY.vue +7 -1
  68. package/src/Select/SelectContent.vue +17 -3
  69. package/src/Select/__test__/SelectUnmountCleanup.vue +43 -0
  70. package/src/YearPicker/YearPickerRoot.vue +1 -1
  71. package/src/test/utils.ts +0 -2
@@ -1,7 +1,7 @@
1
1
  import "./index2.cjs";
2
2
  import "./index3.cjs";
3
3
  import { MenuArrowProps, MenuCheckboxItemEmits, MenuCheckboxItemProps, MenuContentEmits, MenuContentProps, MenuEmits, MenuGroupProps, MenuItemEmits, MenuItemIndicatorProps, MenuItemProps, MenuLabelProps, MenuPortalProps, MenuProps, MenuRadioGroupEmits, MenuRadioGroupProps, MenuRadioItemEmits, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentEmits, MenuSubContentProps, MenuSubEmits, MenuSubProps, MenuSubTriggerProps, PopperAnchorProps, _default$277 as _default$13, _default$278 as _default$8, _default$279 as _default, _default$280 as _default$6, _default$281 as _default$10, _default$282 as _default$3, _default$283 as _default$14, _default$284 as _default$12, _default$285 as _default$2, _default$286 as _default$1, _default$287 as _default$11, _default$288 as _default$7, _default$290 as _default$9, _default$291 as _default$4, _default$292 as _default$5, injectMenuContext, injectMenuRootContext } from "./index4.cjs";
4
- import * as vue1947 from "vue";
4
+ import * as vue41 from "vue";
5
5
 
6
6
  //#region src/Menu/MenuAnchor.vue.d.ts
7
7
  interface MenuAnchorProps extends PopperAnchorProps {}
@@ -9,7 +9,7 @@ declare var __VLS_8: {};
9
9
  type __VLS_Slots = {} & {
10
10
  default?: (props: typeof __VLS_8) => any;
11
11
  };
12
- declare const __VLS_base: vue1947.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue1947.ComponentOptionsMixin, vue1947.ComponentOptionsMixin, {}, string, vue1947.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue1947.ComponentProvideOptions, false, {}, any>;
12
+ declare const __VLS_base: vue41.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue41.ComponentOptionsMixin, vue41.ComponentOptionsMixin, {}, string, vue41.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue41.ComponentProvideOptions, false, {}, any>;
13
13
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
14
  declare const _default$15: typeof __VLS_export;
15
15
  type __VLS_WithSlots<T, S> = T & {
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.cts","names":[],"sources":["../src/Menu/MenuAnchor.vue"],"sourcesContent":[],"mappings":";;;;;;UAoBU,eAAA,SAAwB;YAsC9B;KACC,WAAA;2BACwB;AA3CqB,CAAA;AAGC,cA2C7C,UALgB,EAKN,OAAA,CAAA,eALM,CAKN,eALM,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAKN,OAAA,CAAA,qBAAA,EAAA,OAAA,CAAA,qBAAA,EALM,CAAA,CAAA,EAAA,MAAA,EAKN,OAAA,CAAA,WAAA,EAAA,QALM,CAKN,eALM,CAAA,GAKN,QALM,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAKN,OAAA,CAAA,uBAAA,EALM,KAAA,EAAA,CAAA,CAAA,EAAA,GAAA,CAAA;AAAA,cAQhB,YAPU,EAOW,eANS,CAAA,OAMc,UANd,EAM0B,WAN1B,CAAA;AAAA,cAMM,WADxC,EAAA,OAE0B,YAF1B;KAGG,eALW,CAAA,CAAA,EAAA,CAAA,CAAA,GAKa,CALb,GAAA;EAAA,MAAA,EAAA;IAAA,MAAA,EAON,CAPM;EAAA,CAAA;CAAA"}
1
+ {"version":3,"file":"internal.d.cts","names":[],"sources":["../src/Menu/MenuAnchor.vue"],"sourcesContent":[],"mappings":";;;;;;UAoBU,eAAA,SAAwB;YAsC9B;KACC,WAAA;2BACwB;AA3CqB,CAAA;AAGC,cA2C7C,UALgB,EAKN,KAAA,CAAA,eALM,CAKN,eALM,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAKN,KAAA,CAAA,qBAAA,EAAA,KAAA,CAAA,qBAAA,EALM,CAAA,CAAA,EAAA,MAAA,EAKN,KAAA,CAAA,WAAA,EAAA,QALM,CAKN,eALM,CAAA,GAKN,QALM,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAKN,KAAA,CAAA,uBAAA,EALM,KAAA,EAAA,CAAA,CAAA,EAAA,GAAA,CAAA;AAAA,cAQhB,YAPU,EAOW,eANS,CAAA,OAMc,UANd,EAM0B,WAN1B,CAAA;AAAA,cAMM,WADxC,EAAA,OAE0B,YAF1B;KAGG,eALW,CAAA,CAAA,EAAA,CAAA,CAAA,GAKa,CALb,GAAA;EAAA,MAAA,EAAA;IAAA,MAAA,EAON,CAPM;EAAA,CAAA;CAAA"}
@@ -1,7 +1,7 @@
1
1
  import "./index2.js";
2
2
  import "./index3.js";
3
3
  import { MenuArrowProps, MenuCheckboxItemEmits, MenuCheckboxItemProps, MenuContentEmits, MenuContentProps, MenuEmits, MenuGroupProps, MenuItemEmits, MenuItemIndicatorProps, MenuItemProps, MenuLabelProps, MenuPortalProps, MenuProps, MenuRadioGroupEmits, MenuRadioGroupProps, MenuRadioItemEmits, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentEmits, MenuSubContentProps, MenuSubEmits, MenuSubProps, MenuSubTriggerProps, PopperAnchorProps, _default$277 as _default$13, _default$278 as _default$8, _default$279 as _default, _default$280 as _default$6, _default$281 as _default$10, _default$282 as _default$3, _default$283 as _default$14, _default$284 as _default$12, _default$285 as _default$2, _default$286 as _default$1, _default$287 as _default$11, _default$288 as _default$7, _default$290 as _default$9, _default$291 as _default$4, _default$292 as _default$5, injectMenuContext, injectMenuRootContext } from "./index4.js";
4
- import * as vue13 from "vue";
4
+ import * as vue88 from "vue";
5
5
 
6
6
  //#region src/Menu/MenuAnchor.vue.d.ts
7
7
  interface MenuAnchorProps extends PopperAnchorProps {}
@@ -9,7 +9,7 @@ declare var __VLS_8: {};
9
9
  type __VLS_Slots = {} & {
10
10
  default?: (props: typeof __VLS_8) => any;
11
11
  };
12
- declare const __VLS_base: vue13.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue13.ComponentProvideOptions, false, {}, any>;
12
+ declare const __VLS_base: vue88.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue88.ComponentOptionsMixin, vue88.ComponentOptionsMixin, {}, string, vue88.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue88.ComponentProvideOptions, false, {}, any>;
13
13
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
14
  declare const _default$15: typeof __VLS_export;
15
15
  type __VLS_WithSlots<T, S> = T & {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "akar",
3
3
  "type": "module",
4
- "version": "2.0.4",
4
+ "version": "2.0.8",
5
5
  "description": "Vue UI primitives components",
6
6
  "author": "Vinicunca Contributors (https://github.com/vinicunca)",
7
7
  "license": "MIT",
@@ -111,14 +111,14 @@
111
111
  "@tsconfig/node24": "^24.0.0",
112
112
  "@types/jsdom": "^28.0.0",
113
113
  "@types/node": "^24.0.13",
114
- "@vitejs/plugin-vue": "^6.0.6",
114
+ "@vitejs/plugin-vue": "^6.0.7",
115
115
  "@vitest/coverage-istanbul": "^3.2.4",
116
116
  "@vue/test-utils": "^2.4.10",
117
117
  "@vue/tsconfig": "^0.7.0",
118
118
  "jsdom": "^26.1.0",
119
119
  "size-limit": "^12.0.1",
120
120
  "tsdown": "^0.12.9",
121
- "vite": "^8.0.10",
121
+ "vite": "^8.0.14",
122
122
  "vitest": "^3.2.4",
123
123
  "vitest-axe": "0.1.0",
124
124
  "vitest-canvas-mock": "^0.3.3",
@@ -96,7 +96,7 @@ export interface CalendarRootProps extends PrimitiveProps {
96
96
  /** A function that returns the previous page of the calendar. It receives the current placeholder as an argument inside the component. */
97
97
  prevPage?: (placeholder: DateValue) => DateValue;
98
98
  /** The controlled selected date value of the calendar. Can be bound as `v-model`. */
99
- modelValue?: DateValue | Array<DateValue> | undefined;
99
+ modelValue?: DateValue | Array<DateValue> | null;
100
100
  /** Whether multiple dates can be selected */
101
101
  multiple?: boolean;
102
102
  /** Whether or not to disable days outside the current view. */
@@ -78,7 +78,20 @@ function handleBlur(ev: FocusEvent) {
78
78
  const isInsideContent = document.getElementById(rootContext.contentId)?.contains(nextFocus);
79
79
 
80
80
  if (!isInsideRoot && !isInsideContent) {
81
- rootContext.onOpenChange(false);
81
+ // Delay to let FocusScope's focus-restoration (handleFocusOut) run first.
82
+ // Without this, closing fires before FocusScope can pull focus back inside,
83
+ // causing a second combobox to immediately close when switching between two.
84
+ requestAnimationFrame(() => {
85
+ if (!rootContext.open.value) {
86
+ return;
87
+ }
88
+ const active = document.activeElement;
89
+ const isStillOutside = !rootContext.parentElement.value?.contains(active)
90
+ && !document.getElementById(rootContext.contentId)?.contains(active);
91
+ if (isStillOutside) {
92
+ rootContext.onOpenChange(false);
93
+ }
94
+ });
82
95
  }
83
96
  }
84
97
 
@@ -82,7 +82,7 @@ export interface DateRangeFieldRootProps extends PrimitiveProps, FormFieldProps
82
82
 
83
83
  export type DateRangeFieldRootEmits = {
84
84
  /** Event handler called whenever the model value changes */
85
- 'update:modelValue': [DateRange];
85
+ 'update:modelValue': [date: DateRange];
86
86
  /** Event handler called whenever the placeholder value changes */
87
87
  'update:placeholder': [date: DateValue];
88
88
  };
@@ -23,6 +23,7 @@ useForwardExpose();
23
23
  :as-child="asChild"
24
24
  :data-state="rootContext.open.value ? 'open' : 'closed'"
25
25
  style="pointer-events: auto"
26
+ @pointerdown.left.self.prevent
26
27
  >
27
28
  <slot />
28
29
  </Primitive>
@@ -195,6 +195,10 @@ watchEffect(async (cleanupFn) => {
195
195
  container.addEventListener(AUTOFOCUS_ON_UNMOUNT, unmountEventHandler);
196
196
  container.dispatchEvent(unmountEvent);
197
197
 
198
+ // Signal that blur events fired below are system-initiated (focus trap
199
+ // cleanup), not user-initiated. Consumers can use this to skip validation.
200
+ container.setAttribute('data-focus-scope-unmounting', '');
201
+
198
202
  setTimeout(() => {
199
203
  if (!unmountEvent.defaultPrevented) {
200
204
  focus(previouslyFocusedElement ?? document.body, { select: true });
@@ -204,6 +208,8 @@ watchEffect(async (cleanupFn) => {
204
208
  container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, unmountEventHandler);
205
209
 
206
210
  focusScopesStack.remove(focusScope);
211
+
212
+ container.removeAttribute('data-focus-scope-unmounting');
207
213
  }, 0);
208
214
  });
209
215
  });
@@ -44,7 +44,7 @@ const { CollectionItem } = useCollection();
44
44
  const { forwardRef, currentElement } = useForwardExpose();
45
45
  const rootContext = injectListboxRootContext();
46
46
 
47
- const isHighlighted = computed(() => currentElement.value === rootContext.highlightedElement.value);
47
+ const isHighlighted = computed(() => currentElement.value != null && currentElement.value === rootContext.highlightedElement.value);
48
48
  const isSelected = computed(() => valueComparator(rootContext.modelValue.value, props.value, rootContext.by));
49
49
 
50
50
  const disabled = computed(() => rootContext.disabled.value || props.disabled);
@@ -77,7 +77,7 @@ provideListboxItemContext({
77
77
  :id="id"
78
78
  v-bind="$attrs"
79
79
  :ref="forwardRef"
80
- v-memo="[isHighlighted, isSelected]"
80
+ v-memo="[isHighlighted, isSelected, disabled, rootContext.focusable.value]"
81
81
  role="option"
82
82
  :tabindex="rootContext.focusable.value ? isHighlighted ? '0' : '-1' : -1"
83
83
  :aria-selected="isSelected"
@@ -33,7 +33,7 @@ const { forwardRef, currentElement } = useForwardExpose();
33
33
  const { CollectionItem } = useCollection();
34
34
 
35
35
  const isFocused = ref(false);
36
- const isHighlighted = computed(() => isFocused.value || (contentContext.highlightedElement.value === currentElement.value));
36
+ const isHighlighted = computed(() => isFocused.value || (currentElement.value != null && contentContext.highlightedElement.value === currentElement.value));
37
37
 
38
38
  async function handlePointerMove(event: PointerEvent) {
39
39
  if (event.defaultPrevented || !isMouseEvent(event)) {
@@ -74,7 +74,7 @@ export interface MonthPickerRootProps extends PrimitiveProps {
74
74
  /** A function that returns the previous page of the month picker. Receives the current placeholder as an argument. */
75
75
  prevPage?: (placeholder: DateValue) => DateValue;
76
76
  /** The controlled selected month value of the month picker. Can be bound as `v-model`. */
77
- modelValue?: DateValue | Array<DateValue> | undefined;
77
+ modelValue?: DateValue | Array<DateValue> | null;
78
78
  /** Whether multiple months can be selected */
79
79
  multiple?: boolean;
80
80
  }
@@ -188,6 +188,10 @@ function handleKeydown(ev: KeyboardEvent) {
188
188
  }
189
189
 
190
190
  function handleDismiss() {
191
+ if (menuContext.modelValue.value !== itemContext.value) {
192
+ return;
193
+ }
194
+
191
195
  const rootContentDismissEvent = new Event(EVENT_ROOT_CONTENT_DISMISS, {
192
196
  bubbles: true,
193
197
  cancelable: true,
@@ -141,12 +141,13 @@ const { delayDuration, skipDelayDuration, dir: propDir, disableClickTrigger, dis
141
141
  const dir = useDirection(propDir);
142
142
 
143
143
  const isDelaySkipped = refAutoReset(false, skipDelayDuration);
144
+ const skipNextClose = ref(false);
144
145
  const computedDelay = computed(() => {
145
146
  const isOpen = modelValue.value !== '';
146
147
  if (isOpen || isDelaySkipped.value) {
147
148
  return 150;
148
- } // 150ms for user to switch trigger or move into content view
149
- else {
149
+ } else {
150
+ // 150ms for user to switch trigger or move into content view
150
151
  return delayDuration.value;
151
152
  }
152
153
  });
@@ -154,8 +155,17 @@ const computedDelay = computed(() => {
154
155
  const debouncedFn = useDebounceFn((val?: string) => {
155
156
  // passing `undefined` meant to reset the debounce timer
156
157
  if (isString(val)) {
158
+ if (val === '' && skipNextClose.value) {
159
+ skipNextClose.value = false;
160
+ return;
161
+ }
162
+
157
163
  previousValue.value = modelValue.value;
158
164
  modelValue.value = val;
165
+
166
+ if (val === '') {
167
+ isDelaySkipped.value = true;
168
+ }
159
169
  }
160
170
  }, computedDelay);
161
171
 
@@ -193,10 +203,16 @@ provideNavigationMenuContext({
193
203
  viewport.value = val;
194
204
  },
195
205
  onTriggerEnter: (val) => {
196
- debouncedFn(val);
206
+ if (modelValue.value !== '') {
207
+ skipNextClose.value = true;
208
+ previousValue.value = modelValue.value;
209
+ modelValue.value = val;
210
+ } else {
211
+ debouncedFn(val);
212
+ }
197
213
  },
198
214
  onTriggerLeave: () => {
199
- isDelaySkipped.value = true;
215
+ skipNextClose.value = false;
200
216
  debouncedFn('');
201
217
  },
202
218
  onContentEnter: () => {
@@ -204,6 +220,7 @@ provideNavigationMenuContext({
204
220
  },
205
221
  onContentLeave: () => {
206
222
  if (!props.disablePointerLeaveClose) {
223
+ skipNextClose.value = false;
207
224
  debouncedFn('');
208
225
  }
209
226
  },
@@ -0,0 +1,45 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue';
3
+ import {
4
+ NavigationMenuContent,
5
+ NavigationMenuItem,
6
+ NavigationMenuList,
7
+ NavigationMenuRoot,
8
+ NavigationMenuTrigger,
9
+ } from '..';
10
+
11
+ const modelValue = ref('');
12
+ </script>
13
+
14
+ <template>
15
+ <NavigationMenuRoot
16
+ v-model="modelValue"
17
+ :unmount-on-hide="false"
18
+ :disable-hover-trigger="true"
19
+ >
20
+ <span data-testid="model-value">{{ modelValue }}</span>
21
+ <NavigationMenuList>
22
+ <NavigationMenuItem value="one">
23
+ <NavigationMenuTrigger data-testid="trigger-one">
24
+ One
25
+ </NavigationMenuTrigger>
26
+ <NavigationMenuContent data-testid="content-one">
27
+ <button data-testid="inside-one">
28
+ Inside one
29
+ </button>
30
+ </NavigationMenuContent>
31
+ </NavigationMenuItem>
32
+
33
+ <NavigationMenuItem value="two">
34
+ <NavigationMenuTrigger data-testid="trigger-two">
35
+ Two
36
+ </NavigationMenuTrigger>
37
+ <NavigationMenuContent data-testid="content-two">
38
+ <button data-testid="inside-two">
39
+ Inside two
40
+ </button>
41
+ </NavigationMenuContent>
42
+ </NavigationMenuItem>
43
+ </NavigationMenuList>
44
+ </NavigationMenuRoot>
45
+ </template>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, onMounted } from 'vue';
2
+ import { computed, onMounted, onUnmounted } from 'vue';
3
3
  import { useForwardExpose } from '@/shared';
4
4
  import { injectScrollAreaRootContext } from './ScrollAreaRoot.vue';
5
5
  import ScrollAreaScrollbarImpl from './ScrollAreaScrollbarImpl.vue';
@@ -16,6 +16,13 @@ onMounted(() => {
16
16
  rootContext.onScrollbarXChange(scrollbarElement.value);
17
17
  }
18
18
  });
19
+
20
+ // Clear the registration on unmount so consumers (e.g. ScrollAreaCorner) don't
21
+ // hold a stale reference once the scrollbar is removed (e.g. between hover cycles).
22
+ onUnmounted(() => {
23
+ rootContext.onScrollbarXChange(null);
24
+ });
25
+
19
26
  const sizes = computed(() => scrollbarVisibleContext.sizes.value);
20
27
  </script>
21
28
 
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, onMounted } from 'vue';
2
+ import { computed, onMounted, onUnmounted } from 'vue';
3
3
  import { useForwardExpose } from '@/shared';
4
4
  import { injectScrollAreaRootContext } from './ScrollAreaRoot.vue';
5
5
  import ScrollAreaScrollbarImpl from './ScrollAreaScrollbarImpl.vue';
@@ -17,6 +17,12 @@ onMounted(() => {
17
17
  }
18
18
  });
19
19
 
20
+ // Clear the registration on unmount so consumers (e.g. ScrollAreaCorner) don't
21
+ // hold a stale reference once the scrollbar is removed (e.g. between hover cycles).
22
+ onUnmounted(() => {
23
+ rootContext.onScrollbarYChange(null);
24
+ });
25
+
20
26
  const sizes = computed(() => scrollbarVisibleContext.sizes.value);
21
27
  </script>
22
28
 
@@ -3,7 +3,7 @@ import type {
3
3
  SelectContentImplEmits,
4
4
  SelectContentImplProps,
5
5
  } from './SelectContentImpl.vue';
6
- import { computed, onMounted, ref, watch } from 'vue';
6
+ import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
7
7
 
8
8
  export type SelectContentEmits = SelectContentImplEmits;
9
9
 
@@ -44,16 +44,30 @@ const presenceRef = ref<InstanceType<typeof Presence>>();
44
44
  const present = computed(() => props.forceMount || rootContext.open.value);
45
45
  const renderPresence = ref(present.value);
46
46
 
47
- watch(present, () => {
47
+ let renderPresenceTimeout: ReturnType<typeof setTimeout> | undefined;
48
+
49
+ function clearRenderPresenceTimeout() {
50
+ if (renderPresenceTimeout) {
51
+ clearTimeout(renderPresenceTimeout);
52
+ renderPresenceTimeout = undefined;
53
+ }
54
+ }
55
+
56
+ watch(present, (_value, _oldValue, onCleanup) => {
48
57
  // Toggle render presence after a delay (nextTick is not enough)
49
58
  // to allow children to re-render with the latest state.
50
59
  // Otherwise, they would remain in the old state during the transition,
51
60
  // which would prevent the animation that depend on state (e.g., data-[state=closed])
52
61
  // from being applied accurately.
53
- setTimeout(() => {
62
+ clearRenderPresenceTimeout();
63
+ renderPresenceTimeout = setTimeout(() => {
54
64
  renderPresence.value = present.value;
65
+ renderPresenceTimeout = undefined;
55
66
  });
67
+ onCleanup(clearRenderPresenceTimeout);
56
68
  });
69
+
70
+ onUnmounted(clearRenderPresenceTimeout);
57
71
  </script>
58
72
 
59
73
  <template>
@@ -0,0 +1,43 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue';
3
+ import {
4
+ SelectContent,
5
+ SelectItem,
6
+ SelectItemText,
7
+ SelectPortal,
8
+ SelectRoot,
9
+ SelectTrigger,
10
+ SelectValue,
11
+ SelectViewport,
12
+ } from '..';
13
+
14
+ const open = ref(true);
15
+ const mounted = ref(true);
16
+ </script>
17
+
18
+ <template>
19
+ <button @click="open = false">
20
+ Close
21
+ </button>
22
+ <button @click="mounted = false">
23
+ Unmount
24
+ </button>
25
+
26
+ <SelectRoot
27
+ v-if="mounted"
28
+ v-model:open="open"
29
+ >
30
+ <SelectTrigger aria-label="Fruit">
31
+ <SelectValue placeholder="Please select a fruit" />
32
+ </SelectTrigger>
33
+ <SelectPortal>
34
+ <SelectContent position="popper">
35
+ <SelectViewport>
36
+ <SelectItem value="apple">
37
+ <SelectItemText>Apple</SelectItemText>
38
+ </SelectItem>
39
+ </SelectViewport>
40
+ </SelectContent>
41
+ </SelectPortal>
42
+ </SelectRoot>
43
+ </template>
@@ -75,7 +75,7 @@ export interface YearPickerRootProps extends PrimitiveProps {
75
75
  /** A function that returns the previous page of the year picker. Receives the current placeholder as an argument. */
76
76
  prevPage?: (placeholder: DateValue) => DateValue;
77
77
  /** The controlled selected year value of the year picker. Can be bound as `v-model`. */
78
- modelValue?: DateValue | Array<DateValue> | undefined;
78
+ modelValue?: DateValue | Array<DateValue> | null;
79
79
  /** Whether multiple years can be selected */
80
80
  multiple?: boolean;
81
81
  /** Number of years to display per page */
package/src/test/utils.ts CHANGED
@@ -5,5 +5,3 @@ export const handleSubmit = vi.fn((e) => {
5
5
  const formData = new FormData(e.target);
6
6
  return Object.fromEntries(formData as any);
7
7
  });
8
-
9
- export const sleep = (duration: number) => new Promise((resolve) => setTimeout(resolve, duration));