[ES|QL] Makes the clear control button optional (#212848)

## Summary

Closes https://github.com/elastic/kibana/issues/212605

Here we are removing the clear button from the ES|QL control as clearing
will result in wrong charts. I also considered the reset but when there
is no changes should be hidden or disabled. This seems to me as a
smaller change and taken under consideration that dashboard already
allows resetting I think it is ok to remove it.

We can always reconsider if any user complains.

Although by removing the clearSelections from the control config removes
the button the `DefaultControlApi ` was marking it as required. So I had
to tweak a bit the types.
This commit is contained in:
Stratoula Kalafateli 2025-03-03 19:03:57 +01:00 committed by GitHub
parent 7f32eb0225
commit f6978eaf7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2 additions and 5 deletions

View file

@ -180,7 +180,7 @@ export const SearchExample = ({ data, dataView, navigation }: Props) => {
onClick={() => {
if (controlGroupAPI) {
Object.values(controlGroupAPI.children$.getValue()).forEach((controlApi) => {
(controlApi as DefaultControlApi)?.clearSelections();
(controlApi as DefaultControlApi)?.clearSelections?.();
});
}
}}

View file

@ -96,9 +96,6 @@ export const getESQLControlFactory = (): ControlFactory<ESQLControlState, ESQLCo
references: [],
};
},
clearSelections: () => {
// do nothing, not allowed for now;
},
},
{
...defaultControl.comparators,

View file

@ -36,7 +36,7 @@ export type DefaultControlApi = PublishesDataLoading &
PublishesBlockingError &
PublishesUnsavedChanges &
Partial<PublishesTitle & PublishesDisabledActionIds & HasCustomPrepend> &
CanClearSelections &
Partial<CanClearSelections> &
HasType &
HasUniqueId &
HasSerializableState<DefaultControlState> &