Skip to content

Commit

Permalink
[Security Solution] Followup fix for #174026 (#175560)
Browse files Browse the repository at this point in the history
## Summary

This is a followup to #174922.
While doing [backport](#175433) of
that PR, I found that tests are failing in 8.12 because of not using
state updating path for updating `filters` property of the component.
This led to stale version of `filters` property being passed to the
`SearchBar` component and thus the initial fix was not working.


[Here](532178b)
is the fix for 8.12 which was cherry-picked here.

### Checklist

- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ESS 50
times](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4955)
- [Serverless 50
times](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4956)
  • Loading branch information
e40pud authored Jan 26, 2024
1 parent c8ada33 commit 0dc09f6
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const QueryBar = memo<QueryBarComponentProps>(
}) => {
const { data } = useKibana().services;
const [dataView, setDataView] = useState<DataView>();
const [searchBarFilters, setSearchBarFilters] = useState<Filter[]>(filters);
const onQuerySubmit = useCallback(
(payload: { dateRange: TimeRange; query?: Query | AggregateQuery }) => {
if (payload.query != null && !deepEqual(payload.query, filterQuery)) {
Expand Down Expand Up @@ -133,7 +134,9 @@ export const QueryBar = memo<QueryBarComponentProps>(
* We update filters and set new data view id to make sure that SearchBar does not show data view picker
* More details in https://github.com/elastic/kibana/issues/174026
*/
filters.forEach((filter) => (filter.meta.index = indexPattern.title));
const updatedFilters = [...filters];
updatedFilters.forEach((filter) => (filter.meta.index = indexPattern.title));
setSearchBarFilters(updatedFilters);
};
createDataView();
}
Expand All @@ -151,7 +154,7 @@ export const QueryBar = memo<QueryBarComponentProps>(
showSubmitButton={false}
dateRangeFrom={dateRangeFrom}
dateRangeTo={dateRangeTo}
filters={filters}
filters={searchBarFilters}
indexPatterns={arrDataView}
isLoading={isLoading}
isRefreshPaused={isRefreshPaused}
Expand Down

0 comments on commit 0dc09f6

Please sign in to comment.