@@ -115,14 +115,20 @@ export class FilterMenuValueList extends Component<Props, SpreadsheetChildEnv> {
115115 this . state . selectedValue = value . string ;
116116 }
117117
118- selectAll ( ) {
119- this . state . displayedValues . forEach ( ( value ) => ( value . checked = true ) ) ;
120- this . props . onUpdateHiddenValues ( [ ] ) ;
118+ get filteredValues ( ) : Value [ ] {
119+ return ! this . state . textFilter
120+ ? this . state . values
121+ : fuzzyLookup ( this . state . textFilter , this . state . values , ( val ) => val . string ) ;
121122 }
122123
123- clearAll ( ) {
124- this . state . displayedValues . forEach ( ( value ) => ( value . checked = false ) ) ;
125- const hiddenValues = this . state . values . map ( ( val ) => val . string ) ;
124+ setAllChecked ( checked : boolean ) {
125+ const filteredValues = new Set ( this . filteredValues ) ;
126+ this . state . values . forEach ( ( value ) => {
127+ if ( filteredValues . has ( value ) ) {
128+ value . checked = checked ;
129+ }
130+ } ) ;
131+ const hiddenValues = this . state . values . filter ( ( val ) => ! val . checked ) . map ( ( val ) => val . string ) ;
126132 this . props . onUpdateHiddenValues ( hiddenValues ) ;
127133 }
128134
@@ -139,11 +145,8 @@ export class FilterMenuValueList extends Component<Props, SpreadsheetChildEnv> {
139145 }
140146
141147 computeDisplayedValues ( ) {
142- const values = ! this . state . textFilter
143- ? this . state . values
144- : fuzzyLookup ( this . state . textFilter , this . state . values , ( val ) => val . string ) ;
145- this . state . displayedValues = values . slice ( 0 , this . state . numberOfDisplayedValues ) ;
146- this . state . hasMoreValues = values . length > this . state . numberOfDisplayedValues ;
148+ this . state . displayedValues = this . filteredValues . slice ( 0 , this . state . numberOfDisplayedValues ) ;
149+ this . state . hasMoreValues = this . filteredValues . length > this . state . numberOfDisplayedValues ;
147150 }
148151
149152 loadMoreValues ( ) {
0 commit comments