@zag-js/popover 1.44.0 → 1.46.0

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.
@@ -125,6 +125,7 @@ var machine = (0, import_core.createMachine)({
125
125
  }
126
126
  },
127
127
  open: {
128
+ entry: ["checkRenderedElements"],
128
129
  effects: [
129
130
  "trapFocus",
130
131
  "preventScroll",
@@ -190,6 +191,7 @@ var machine = (0, import_core.createMachine)({
190
191
  pointerBlocking: prop("modal"),
191
192
  exclude: [dom.getTriggerEl(scope), ...dom.getTriggerEls(scope)].filter(Boolean),
192
193
  defer: true,
194
+ layerStyleTargets: [() => dom.getPositionerEl(scope)],
193
195
  onEscapeKeyDown(event) {
194
196
  prop("onEscapeKeyDown")?.(event);
195
197
  if (prop("closeOnEscape")) return;
@@ -281,7 +283,7 @@ var machine = (0, import_core.createMachine)({
281
283
  },
282
284
  checkRenderedElements({ context, scope }) {
283
285
  (0, import_dom_query.raf)(() => {
284
- Object.assign(context.get("renderedElements"), {
286
+ context.set("renderedElements", {
285
287
  title: !!dom.getTitleEl(scope),
286
288
  description: !!dom.getDescriptionEl(scope)
287
289
  });
@@ -295,7 +297,8 @@ var machine = (0, import_core.createMachine)({
295
297
  getInitialEl: prop("initialFocusEl"),
296
298
  enabled: prop("autoFocus")
297
299
  });
298
- element?.focus({ preventScroll: true });
300
+ if (!element) return;
301
+ element.focus({ preventScroll: true });
299
302
  });
300
303
  },
301
304
  setFinalFocus({ event, prop, scope, context }) {
@@ -91,6 +91,7 @@ var machine = createMachine({
91
91
  }
92
92
  },
93
93
  open: {
94
+ entry: ["checkRenderedElements"],
94
95
  effects: [
95
96
  "trapFocus",
96
97
  "preventScroll",
@@ -156,6 +157,7 @@ var machine = createMachine({
156
157
  pointerBlocking: prop("modal"),
157
158
  exclude: [dom.getTriggerEl(scope), ...dom.getTriggerEls(scope)].filter(Boolean),
158
159
  defer: true,
160
+ layerStyleTargets: [() => dom.getPositionerEl(scope)],
159
161
  onEscapeKeyDown(event) {
160
162
  prop("onEscapeKeyDown")?.(event);
161
163
  if (prop("closeOnEscape")) return;
@@ -247,7 +249,7 @@ var machine = createMachine({
247
249
  },
248
250
  checkRenderedElements({ context, scope }) {
249
251
  raf(() => {
250
- Object.assign(context.get("renderedElements"), {
252
+ context.set("renderedElements", {
251
253
  title: !!dom.getTitleEl(scope),
252
254
  description: !!dom.getDescriptionEl(scope)
253
255
  });
@@ -261,7 +263,8 @@ var machine = createMachine({
261
263
  getInitialEl: prop("initialFocusEl"),
262
264
  enabled: prop("autoFocus")
263
265
  });
264
- element?.focus({ preventScroll: true });
266
+ if (!element) return;
267
+ element.focus({ preventScroll: true });
265
268
  });
266
269
  },
267
270
  setFinalFocus({ event, prop, scope, context }) {
@@ -65,8 +65,9 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
65
65
  autoFocus?: boolean | undefined;
66
66
  /**
67
67
  * The element to focus on when the popover is opened.
68
+ * Return `false` to skip moving focus, or `null` to use the default.
68
69
  */
69
- initialFocusEl?: (() => HTMLElement | null) | undefined;
70
+ initialFocusEl?: (() => HTMLElement | null | false) | undefined;
70
71
  /**
71
72
  * Element to receive focus when the popover is closed.
72
73
  */
@@ -65,8 +65,9 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
65
65
  autoFocus?: boolean | undefined;
66
66
  /**
67
67
  * The element to focus on when the popover is opened.
68
+ * Return `false` to skip moving focus, or `null` to use the default.
68
69
  */
69
- initialFocusEl?: (() => HTMLElement | null) | undefined;
70
+ initialFocusEl?: (() => HTMLElement | null | false) | undefined;
70
71
  /**
71
72
  * Element to receive focus when the popover is closed.
72
73
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popover",
3
- "version": "1.44.0",
3
+ "version": "1.46.0",
4
4
  "description": "Core logic for the popover widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,16 +29,16 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/anatomy": "1.44.0",
33
- "@zag-js/aria-hidden": "1.44.0",
34
- "@zag-js/core": "1.44.0",
35
- "@zag-js/dom-query": "1.44.0",
36
- "@zag-js/utils": "1.44.0",
37
- "@zag-js/dismissable": "1.44.0",
38
- "@zag-js/popper": "1.44.0",
39
- "@zag-js/remove-scroll": "1.44.0",
40
- "@zag-js/types": "1.44.0",
41
- "@zag-js/focus-trap": "1.44.0"
32
+ "@zag-js/anatomy": "1.46.0",
33
+ "@zag-js/aria-hidden": "1.46.0",
34
+ "@zag-js/core": "1.46.0",
35
+ "@zag-js/dom-query": "1.46.0",
36
+ "@zag-js/utils": "1.46.0",
37
+ "@zag-js/dismissable": "1.46.0",
38
+ "@zag-js/popper": "1.46.0",
39
+ "@zag-js/remove-scroll": "1.46.0",
40
+ "@zag-js/types": "1.46.0",
41
+ "@zag-js/focus-trap": "1.46.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "clean-package": "2.2.0"