@@ -198,10 +198,10 @@ export class SelectSingleRootState extends SelectBaseRootState {
198
198
readonly hasValue = $derived . by ( ( ) => this . opts . value . current !== "" ) ;
199
199
readonly currentLabel = $derived . by ( ( ) => {
200
200
if ( ! this . opts . items . current . length ) return "" ;
201
- const match = this . opts . items . current . find (
202
- ( item ) => item . value === this . opts . value . current
203
- ) ?. label ;
204
- return match ?? "" ;
201
+ return (
202
+ this . opts . items . current . find ( ( item ) => item . value === this . opts . value . current ) ?. label ??
203
+ ""
204
+ ) ;
205
205
} ) ;
206
206
readonly candidateLabels = $derived . by ( ( ) => {
207
207
if ( ! this . opts . items . current . length ) return [ ] ;
@@ -239,8 +239,11 @@ export class SelectSingleRootState extends SelectBaseRootState {
239
239
}
240
240
241
241
toggleItem ( itemValue : string , itemLabel : string = itemValue ) {
242
- this . opts . value . current = this . includesItem ( itemValue ) ? "" : itemValue ;
243
- this . opts . inputValue . current = itemLabel ;
242
+ const newValue = this . includesItem ( itemValue ) ? "" : itemValue ;
243
+ this . opts . value . current = newValue ;
244
+ if ( newValue !== "" ) {
245
+ this . opts . inputValue . current = itemLabel ;
246
+ }
244
247
}
245
248
246
249
setInitialHighlightedNode ( ) {
@@ -1054,8 +1057,6 @@ export class SelectItemState {
1054
1057
*/
1055
1058
onpointerup ( e : BitsPointerEvent ) {
1056
1059
if ( e . defaultPrevented || ! this . opts . ref . current ) return ;
1057
- // prevent any default behavior
1058
-
1059
1060
/**
1060
1061
* For one reason or another, when it's a touch pointer and _not_ on IOS,
1061
1062
* we need to listen for the immediate click event to handle the selection,
@@ -1377,6 +1378,22 @@ export class SelectScrollDownButtonState {
1377
1378
return on ( this . content . viewportNode , "scroll" , ( ) => this . handleScroll ( ) ) ;
1378
1379
} ) ;
1379
1380
1381
+ /**
1382
+ * If the input value changes, this means that the filtered items may have changed,
1383
+ * so we need to re-evaluate the scroll-ability of the list.
1384
+ */
1385
+ watch (
1386
+ [
1387
+ ( ) => this . root . opts . inputValue . current ,
1388
+ ( ) => this . content . viewportNode ,
1389
+ ( ) => this . content . isPositioned ,
1390
+ ] ,
1391
+ ( ) => {
1392
+ if ( ! this . content . viewportNode || ! this . content . isPositioned ) return ;
1393
+ this . handleScroll ( true ) ;
1394
+ }
1395
+ ) ;
1396
+
1380
1397
watch (
1381
1398
( ) => this . scrollButtonState . mounted ,
1382
1399
( ) => {
0 commit comments