Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCI] Standardize error handling for query input in the SearchBar #4182

Open
SergeyMyssak opened this issue May 31, 2023 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@SergeyMyssak
Copy link
Contributor

SergeyMyssak commented May 31, 2023

Is your feature request related to a problem? Please describe.

After auditing advanced_settings and saved_objects_management plugins - #3963 (comment), it was discovered that the same code is used to control query change callback of the OuiSearchBar in two places.

Describe the solution you'd like

This problem aims to discuss options to standardize this process:

  1. Add functionality to the OuiSearchBar (OUI library) component to automatically display an error inside of the component if an incorrect query is entered.
  2. Implement a hook that control the onChange callback and consequently returns an error if required (in Dashboards).

Additional context

search.tsx (advanced_settings)

onChange = ({ query, error }: { query: Query | null; error: { message: string } | null }) => {
if (error) {
this.setState({
isSearchTextValid: false,
parseErrorMessage: error.message,
});
return;
}
this.setState({
isSearchTextValid: true,
parseErrorMessage: null,
});
this.props.onQueryChange({ query: query! });
};

table.tsx (saved_objects_management)

onChange = ({ query, error }: any) => {
if (error) {
this.setState({
isSearchTextValid: false,
parseErrorMessage: error.message,
});
return;
}
this.setState({
isSearchTextValid: true,
parseErrorMessage: null,
});
this.props.onQueryChange({ query });
};

@joshuarrrr
Copy link
Member

@SergeyMyssak Let's hold off on any implementation here until we tackle updates in #4329 (and get similar design guidance for Saved Object Management). The underlying problem in both cases is that the OUI component is more tailored for queries (which may be invalid), than for simple search cases. Arguably in both of these usages, there should not be any need for invalid query handling, if we're just filtering a list of objects for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants