@@ -198,10 +198,10 @@ export class SelectSingleRootState extends SelectBaseRootState {
198198 readonly hasValue = $derived . by ( ( ) => this . opts . value . current !== "" ) ;
199199 readonly currentLabel = $derived . by ( ( ) => {
200200 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+ ) ;
205205 } ) ;
206206 readonly candidateLabels = $derived . by ( ( ) => {
207207 if ( ! this . opts . items . current . length ) return [ ] ;
@@ -239,8 +239,11 @@ export class SelectSingleRootState extends SelectBaseRootState {
239239 }
240240
241241 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+ }
244247 }
245248
246249 setInitialHighlightedNode ( ) {
@@ -1054,8 +1057,6 @@ export class SelectItemState {
10541057 */
10551058 onpointerup ( e : BitsPointerEvent ) {
10561059 if ( e . defaultPrevented || ! this . opts . ref . current ) return ;
1057- // prevent any default behavior
1058-
10591060 /**
10601061 * For one reason or another, when it's a touch pointer and _not_ on IOS,
10611062 * we need to listen for the immediate click event to handle the selection,
@@ -1377,6 +1378,22 @@ export class SelectScrollDownButtonState {
13771378 return on ( this . content . viewportNode , "scroll" , ( ) => this . handleScroll ( ) ) ;
13781379 } ) ;
13791380
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+
13801397 watch (
13811398 ( ) => this . scrollButtonState . mounted ,
13821399 ( ) => {
0 commit comments