[EuiSelectable] list not filtered when onChange
or onSearch
included in searchProps
#4132
Labels
onChange
or onSearch
included in searchProps
#4132
When
searchable
and one or more ofsearchProps.onChange
andsearchProps.onSearch
is passed toEuiSelectable
, the options are not correctly filtered in the UI. I created a sandbox showing both issues.Code
I believe in both cases the
searchProps
are being spread over more important props, which seems unintended.onChange
eui/src/components/selectable/selectable.tsx
Lines 534 to 551 in 01c6986
onChange={this.onSearchChange}
appears to be key to updating the selectable internal state{...cleanedSearchProps}
overrides itonSearch
I'm less sure about the cause of this issue, but have a feeling it could be:
eui/src/components/selectable/selectable_search/selectable_search.tsx
Lines 113 to 125 in 01c6986
onSearch
can exist in...rest
(which comes fromcleanedSearchProps
above), overriding the important call tothis.onSearchChange
Context
The feature I'm working on extends the
EuiSelectable
component, by adding "Select all" and "Select none" buttons above thesearchable
EuiSelectable
. Here's an example of the UI.This works without any hassle. I update the local
options
state when a user clicks on either button, and pass this state down toEuiSelectable
. After building this, I realized that it would be a better UX to combine this behaviour with the client-side search offered by addingsearchable
. In my current implementation the user could filter (let's say to view 5 of 100 items), then click "Select all". This would select not only the visible/filtered options, but all of them.To fix this UX issue, I tried to access the currently filtered items. I found I could do this as shown:
Elsewhere, I could use this data to compare the
filteredOptions
andoptions
, and work out whichoptions
should be updated when a user clicks on one of the Select all/none buttons. Again, no problems here.I believe the data-flow is working fine using the existing props, and the only issue is that my combination of props prevents the
EuiSelectable
from accurately reflecting the search filters in the UI.The text was updated successfully, but these errors were encountered: