bits-ui 2.11.3 → 2.11.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.
@@ -425,6 +425,7 @@ function safeInsertRule(sheet, rule) {
425
425
  sheet.insertRule(rule);
426
426
  }
427
427
  catch {
428
+ // oxlint-disable-next-line no-console
428
429
  console.error("pin input could not insert CSS rule:", rule);
429
430
  }
430
431
  }
@@ -132,8 +132,8 @@ export class SelectSingleRootState extends SelectBaseRootState {
132
132
  currentLabel = $derived.by(() => {
133
133
  if (!this.opts.items.current.length)
134
134
  return "";
135
- const match = this.opts.items.current.find((item) => item.value === this.opts.value.current)?.label;
136
- return match ?? "";
135
+ return (this.opts.items.current.find((item) => item.value === this.opts.value.current)?.label ??
136
+ "");
137
137
  });
138
138
  candidateLabels = $derived.by(() => {
139
139
  if (!this.opts.items.current.length)
@@ -166,8 +166,11 @@ export class SelectSingleRootState extends SelectBaseRootState {
166
166
  return this.opts.value.current === itemValue;
167
167
  }
168
168
  toggleItem(itemValue, itemLabel = itemValue) {
169
- this.opts.value.current = this.includesItem(itemValue) ? "" : itemValue;
170
- this.opts.inputValue.current = itemLabel;
169
+ const newValue = this.includesItem(itemValue) ? "" : itemValue;
170
+ this.opts.value.current = newValue;
171
+ if (newValue !== "") {
172
+ this.opts.inputValue.current = itemLabel;
173
+ }
171
174
  }
172
175
  setInitialHighlightedNode() {
173
176
  afterTick(() => {
@@ -836,7 +839,6 @@ export class SelectItemState {
836
839
  onpointerup(e) {
837
840
  if (e.defaultPrevented || !this.opts.ref.current)
838
841
  return;
839
- // prevent any default behavior
840
842
  /**
841
843
  * For one reason or another, when it's a touch pointer and _not_ on IOS,
842
844
  * we need to listen for the immediate click event to handle the selection,
@@ -1083,6 +1085,19 @@ export class SelectScrollDownButtonState {
1083
1085
  this.handleScroll(true);
1084
1086
  return on(this.content.viewportNode, "scroll", () => this.handleScroll());
1085
1087
  });
1088
+ /**
1089
+ * If the input value changes, this means that the filtered items may have changed,
1090
+ * so we need to re-evaluate the scroll-ability of the list.
1091
+ */
1092
+ watch([
1093
+ () => this.root.opts.inputValue.current,
1094
+ () => this.content.viewportNode,
1095
+ () => this.content.isPositioned,
1096
+ ], () => {
1097
+ if (!this.content.viewportNode || !this.content.isPositioned)
1098
+ return;
1099
+ this.handleScroll(true);
1100
+ });
1086
1101
  watch(() => this.scrollButtonState.mounted, () => {
1087
1102
  if (!this.scrollButtonState.mounted)
1088
1103
  return;
@@ -10,5 +10,6 @@ export function warn(...messages) {
10
10
  if (set.has(msg))
11
11
  return;
12
12
  set.add(msg);
13
+ // oxlint-disable-next-line no-console
13
14
  console.warn(`[Bits UI]: ${msg}`);
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "2.11.3",
3
+ "version": "2.11.4",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",