bits-ui 2.14.3 → 2.14.4
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.
|
@@ -134,6 +134,10 @@ export class CommandRootState {
|
|
|
134
134
|
if (!this._commandState.value || !this.#isInitialMount) {
|
|
135
135
|
this.#selectFirstItem();
|
|
136
136
|
}
|
|
137
|
+
else if (this.#isInitialMount && this._commandState.value) {
|
|
138
|
+
// scroll the initial value into view if it exists
|
|
139
|
+
this.#scrollInitialValue();
|
|
140
|
+
}
|
|
137
141
|
return;
|
|
138
142
|
}
|
|
139
143
|
const scores = this._commandState.filtered.items;
|
|
@@ -216,6 +220,19 @@ export class CommandRootState {
|
|
|
216
220
|
this.#isInitialMount = false;
|
|
217
221
|
});
|
|
218
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Scrolls the initial value into view if it exists and is not the first item.
|
|
225
|
+
* Called during initial mount when a value is provided.
|
|
226
|
+
*/
|
|
227
|
+
#scrollInitialValue() {
|
|
228
|
+
afterTick(() => {
|
|
229
|
+
const shouldPreventScroll = this.opts.disableInitialScroll.current;
|
|
230
|
+
if (!shouldPreventScroll) {
|
|
231
|
+
this.#scrollSelectedIntoView();
|
|
232
|
+
}
|
|
233
|
+
this.#isInitialMount = false;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
219
236
|
/**
|
|
220
237
|
* Updates filtered items/groups based on search.
|
|
221
238
|
* Recalculates scores and filtered count.
|