@zag-js/combobox 1.3.1 → 1.3.3

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.
package/dist/index.js CHANGED
@@ -137,7 +137,8 @@ function connect(service, normalize) {
137
137
  getInputEl(scope)?.focus();
138
138
  },
139
139
  setOpen(nextOpen) {
140
- if (nextOpen === open) return;
140
+ const open2 = state.hasTag("open");
141
+ if (open2 === nextOpen) return;
141
142
  send({ type: nextOpen ? "OPEN" : "CLOSE" });
142
143
  },
143
144
  getRootProps() {
@@ -1259,15 +1260,13 @@ var machine = core.createMachine({
1259
1260
  }
1260
1261
  });
1261
1262
  },
1262
- syncInputValue({ context, scope }) {
1263
+ syncInputValue({ context, scope, event }) {
1263
1264
  const inputEl = getInputEl(scope);
1264
1265
  if (!inputEl) return;
1265
1266
  inputEl.value = context.get("inputValue");
1266
1267
  queueMicrotask(() => {
1267
- const { selectionStart, selectionEnd } = inputEl;
1268
- if (Math.abs((selectionEnd ?? 0) - (selectionStart ?? 0)) !== 0) return;
1269
- if (selectionStart !== 0) return;
1270
- inputEl.setSelectionRange(inputEl.value.length, inputEl.value.length);
1268
+ if (event.current().type === "INPUT.CHANGE") return;
1269
+ domQuery.setCaretToEnd(inputEl);
1271
1270
  });
1272
1271
  },
1273
1272
  setInputValue({ context, event }) {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { ListCollection } from '@zag-js/collection';
3
- import { raf, observeAttributes, observeChildren, clickIfLink, scrollIntoView, query, dataAttr, ariaAttr, isDownloadingEvent, isOpeningInNewTab, isContextMenuEvent, getEventKey, isLeftClick, isComposingEvent, isAnchorElement } from '@zag-js/dom-query';
3
+ import { raf, setCaretToEnd, observeAttributes, observeChildren, clickIfLink, scrollIntoView, query, dataAttr, ariaAttr, isDownloadingEvent, isOpeningInNewTab, isContextMenuEvent, getEventKey, isLeftClick, isComposingEvent, isAnchorElement } from '@zag-js/dom-query';
4
4
  import { getPlacement, getPlacementStyles } from '@zag-js/popper';
5
5
  import { match, remove, addOrRemove, isBoolean, isEqual, createSplitProps, ensure } from '@zag-js/utils';
6
6
  import { ariaHidden } from '@zag-js/aria-hidden';
@@ -135,7 +135,8 @@ function connect(service, normalize) {
135
135
  getInputEl(scope)?.focus();
136
136
  },
137
137
  setOpen(nextOpen) {
138
- if (nextOpen === open) return;
138
+ const open2 = state.hasTag("open");
139
+ if (open2 === nextOpen) return;
139
140
  send({ type: nextOpen ? "OPEN" : "CLOSE" });
140
141
  },
141
142
  getRootProps() {
@@ -1257,15 +1258,13 @@ var machine = createMachine({
1257
1258
  }
1258
1259
  });
1259
1260
  },
1260
- syncInputValue({ context, scope }) {
1261
+ syncInputValue({ context, scope, event }) {
1261
1262
  const inputEl = getInputEl(scope);
1262
1263
  if (!inputEl) return;
1263
1264
  inputEl.value = context.get("inputValue");
1264
1265
  queueMicrotask(() => {
1265
- const { selectionStart, selectionEnd } = inputEl;
1266
- if (Math.abs((selectionEnd ?? 0) - (selectionStart ?? 0)) !== 0) return;
1267
- if (selectionStart !== 0) return;
1268
- inputEl.setSelectionRange(inputEl.value.length, inputEl.value.length);
1266
+ if (event.current().type === "INPUT.CHANGE") return;
1267
+ setCaretToEnd(inputEl);
1269
1268
  });
1270
1269
  },
1271
1270
  setInputValue({ context, event }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/combobox",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Core logic for the combobox widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,15 +26,15 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.3.1",
30
- "@zag-js/aria-hidden": "1.3.1",
31
- "@zag-js/collection": "1.3.1",
32
- "@zag-js/core": "1.3.1",
33
- "@zag-js/dismissable": "1.3.1",
34
- "@zag-js/dom-query": "1.3.1",
35
- "@zag-js/utils": "1.3.1",
36
- "@zag-js/popper": "1.3.1",
37
- "@zag-js/types": "1.3.1"
29
+ "@zag-js/aria-hidden": "1.3.3",
30
+ "@zag-js/core": "1.3.3",
31
+ "@zag-js/dom-query": "1.3.3",
32
+ "@zag-js/utils": "1.3.3",
33
+ "@zag-js/popper": "1.3.3",
34
+ "@zag-js/types": "1.3.3",
35
+ "@zag-js/anatomy": "1.3.3",
36
+ "@zag-js/collection": "1.3.3",
37
+ "@zag-js/dismissable": "1.3.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "clean-package": "2.2.0"