@ariakit/core 0.4.8 → 0.4.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @ariakit/core
2
2
 
3
+ ## 0.4.10
4
+
5
+ ### Tabs inside animated Combobox or Select
6
+
7
+ When rendering [Tab](https://ariakit.org/components/tab) inside [Combobox](https://ariakit.org/components/combobox) or [Select](https://ariakit.org/components/select), it now waits for the closing animation to finish before restoring the tab with the selected item. This should prevent an inconsistent UI where the tab is restored immediately while the content is still animating out. See [Select with Combobox and Tabs](https://ariakit.org/examples/select-combobox-tab).
8
+
9
+ ### Other updates
10
+
11
+ - Updated [Combobox](https://ariakit.org/components/combobox) to immediately reset the [`activeId`](https://ariakit.org/reference/use-combobox-store#activeid) upon closing the popover.
12
+ - Improved JSDocs.
13
+
14
+ ## 0.4.9
15
+
16
+ - Improved JSDocs.
17
+
3
18
  ## 0.4.8
4
19
 
5
20
  - Added a README file to the package.
@@ -138,8 +138,8 @@ function createComboboxStore(_a = {}) {
138
138
  );
139
139
  _3QF3ODTRcjs.setup.call(void 0,
140
140
  combobox,
141
- () => _3QF3ODTRcjs.batch.call(void 0, combobox, ["mounted"], (state) => {
142
- if (state.mounted) return;
141
+ () => _3QF3ODTRcjs.sync.call(void 0, combobox, ["open"], (state) => {
142
+ if (state.open) return;
143
143
  combobox.setState("activeId", activeId);
144
144
  combobox.setState("moves", 0);
145
145
  })
@@ -97,9 +97,14 @@ function createTabStore(_a = {}) {
97
97
  tab.setState("selectedId", tabItem.id);
98
98
  })
99
99
  );
100
+ let syncActiveId = true;
100
101
  _3QF3ODTRcjs.setup.call(void 0,
101
102
  tab,
102
103
  () => _3QF3ODTRcjs.batch.call(void 0, tab, ["selectedId"], (state, prev) => {
104
+ if (!syncActiveId) {
105
+ syncActiveId = true;
106
+ return;
107
+ }
103
108
  if (parentComposite && state.selectedId === prev.selectedId) return;
104
109
  tab.setState("activeId", state.selectedId);
105
110
  })
@@ -144,18 +149,19 @@ function createTabStore(_a = {}) {
144
149
  selectedIdFromSelectedValue = tab.getState().selectedId;
145
150
  };
146
151
  const restoreSelectedId = () => {
152
+ syncActiveId = false;
147
153
  tab.setState("selectedId", selectedIdFromSelectedValue);
148
154
  };
149
155
  if (parentComposite && "setSelectElement" in parentComposite) {
150
156
  return _BTUHABP4cjs.chain.call(void 0,
151
157
  _3QF3ODTRcjs.sync.call(void 0, parentComposite, ["value"], backupSelectedId),
152
- _3QF3ODTRcjs.sync.call(void 0, parentComposite, ["open"], restoreSelectedId)
158
+ _3QF3ODTRcjs.sync.call(void 0, parentComposite, ["mounted"], restoreSelectedId)
153
159
  );
154
160
  }
155
161
  if (!combobox) return;
156
162
  return _BTUHABP4cjs.chain.call(void 0,
157
163
  _3QF3ODTRcjs.sync.call(void 0, combobox, ["selectedValue"], backupSelectedId),
158
- _3QF3ODTRcjs.sync.call(void 0, combobox, ["open"], restoreSelectedId)
164
+ _3QF3ODTRcjs.sync.call(void 0, combobox, ["mounted"], restoreSelectedId)
159
165
  );
160
166
  });
161
167
  return _3IVNQNIVcjs.__spreadProps.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, composite), tab), {
@@ -138,8 +138,8 @@ function createComboboxStore(_a = {}) {
138
138
  );
139
139
  setup(
140
140
  combobox,
141
- () => batch(combobox, ["mounted"], (state) => {
142
- if (state.mounted) return;
141
+ () => sync(combobox, ["open"], (state) => {
142
+ if (state.open) return;
143
143
  combobox.setState("activeId", activeId);
144
144
  combobox.setState("moves", 0);
145
145
  })
@@ -97,9 +97,14 @@ function createTabStore(_a = {}) {
97
97
  tab.setState("selectedId", tabItem.id);
98
98
  })
99
99
  );
100
+ let syncActiveId = true;
100
101
  setup(
101
102
  tab,
102
103
  () => batch(tab, ["selectedId"], (state, prev) => {
104
+ if (!syncActiveId) {
105
+ syncActiveId = true;
106
+ return;
107
+ }
103
108
  if (parentComposite && state.selectedId === prev.selectedId) return;
104
109
  tab.setState("activeId", state.selectedId);
105
110
  })
@@ -144,18 +149,19 @@ function createTabStore(_a = {}) {
144
149
  selectedIdFromSelectedValue = tab.getState().selectedId;
145
150
  };
146
151
  const restoreSelectedId = () => {
152
+ syncActiveId = false;
147
153
  tab.setState("selectedId", selectedIdFromSelectedValue);
148
154
  };
149
155
  if (parentComposite && "setSelectElement" in parentComposite) {
150
156
  return chain(
151
157
  sync(parentComposite, ["value"], backupSelectedId),
152
- sync(parentComposite, ["open"], restoreSelectedId)
158
+ sync(parentComposite, ["mounted"], restoreSelectedId)
153
159
  );
154
160
  }
155
161
  if (!combobox) return;
156
162
  return chain(
157
163
  sync(combobox, ["selectedValue"], backupSelectedId),
158
- sync(combobox, ["open"], restoreSelectedId)
164
+ sync(combobox, ["mounted"], restoreSelectedId)
159
165
  );
160
166
  });
161
167
  return __spreadProps(__spreadValues(__spreadValues({}, composite), tab), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariakit/core",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Ariakit core",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",