Customising AntD Value Select Searching #827
A-EbrahimRSA
started this conversation in
General
Replies: 1 comment 2 replies
-
You can also replace all value selectors, including the ones used by the value editor component, with the const CustomValueSelector = (props: ValueSelectorProps) => (
<AntDValueSelector {...props} showSearch optionFilterProp='label' />
);
export const App = () => {
return (
<QueryBuilder controlElements={{ valueSelector: CustomValueSelector }} />
);
}
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've recently encountered an issue where I've noticed that when using the AntD styling library and using fields in a specific manner results in unintended behaviour of the search operations.
Taking the below example where I have a field of country which will display country names as labels within the multiselect.
When trying to search the AntD dropdown for a desired country things go awry. This is due to the underlying default behaviour of the Ant Design Select component. By default it searches by value and not by label, which I think is a little unintuitive and silly.
However it does provide some ways of overriding this default behaviour such as providing a value for the following props of the Select component.
My current work around is to create a custom Value Selector and then provide the above properties to indicate that the label should be used for filtering and not the value. I have just used the actual implementation of AntDValueSelector in RQB as a skeleton to work off for now. https://github.com/react-querybuilder/react-querybuilder/blob/main/packages/antd/src/AntDValueSelector.tsx
In a generic sense would it be possible to allow for pass through of props from the styling components i.e. AntDValueSelector, AntDValueEditor, etc.. to the underlying component.
So props for AntDValueSelector would be: AntDValueSelect as well as . I understand that there is definitely going to be some conflict regarding prop name conflicts, but this would allow for each styling library to effectively expose all its internal prop options without needing to completely
As I was typing this I realised that the extraProps field is exactly that. My custom value selector now looks as below.
#304 Is the MR that addresses this issue. Nice work
Beta Was this translation helpful? Give feedback.
All reactions