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

feat(mui5):introducing isFilterCaseInSensitive prop for dual-list-select filterOption #1472

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface InternalDualListSelectProps {
filterOptionsText?: ReactNode;
leftValues?: DualListSelectValue[];
rightValues?: DualListSelectValue[];
isFilterCaseInSensitive?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to not use prop for it and set it as a default behavior.

@Hyperkid123 what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go for default as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising new PR: #1473, closing this one.

WrapperProps?: React.HTMLProps<HTMLDivElement>;
LeftWrapperProps?: React.HTMLProps<HTMLDivElement>;
RightWrapperProps?: React.HTMLProps<HTMLDivElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ DualListInternal.propTypes = {
filterValues: PropTypes.func,
rightValues: PropTypes.array,
handleValuesClick: PropTypes.func,
isFilterCaseInSensitive: PropTypes.bool,
WrapperProps: PropTypes.object,
LeftWrapperProps: PropTypes.object,
RightWrapperProps: PropTypes.object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface InternalDualListSelectProps {
sortValuesTitle?: string;
filterOptionsText?: ReactNode;
filterValueText?: ReactNode;
isFilterCaseInSensitive?: boolean;
FormGroupProps?: CarbonFormGroups;
GridProps?: GridDefaultProps;
RowProps?: RowDefaultProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ DualListSelectInner.propTypes = {
sortValuesTitle: PropTypes.string,
filterOptionsText: PropTypes.node,
filterValueText: PropTypes.node,
isFilterCaseInSensitive: PropTypes.bool,
FormGroupProps: PropTypes.object,
GridProps: PropTypes.object,
RowProps: PropTypes.object,
Expand Down
16 changes: 14 additions & 2 deletions packages/common/src/dual-list-select/dual-list-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,22 @@ const DualListSelectCommon = (props) => {
});

const leftValues = rest.options
.filter((option) => !rest.input.value.includes(option.value) && option.label.includes(state.filterOptions))
.filter((option) => {
if (!props.isFilterCaseInSensitive) {
return !rest.input.value.includes(option.value) && option.label.includes(state.filterOptions);
} else {
return !rest.input.value.includes(option.value) && option.label.toLowerCase().includes(state.filterOptions.toLowerCase());
}
})
.sort((a, b) => (state.sortLeftDesc ? a.label.localeCompare(b.label) : b.label.localeCompare(a.label)));
const rightValues = rest.options
.filter((option) => rest.input.value.includes(option.value) && option.label.includes(state.filterValue))
.filter((option) => {
if (!props.isFilterCaseInSensitive) {
return rest.input.value.includes(option.value) && option.label.includes(state.filterValue);
} else {
return rest.input.value.includes(option.value) && option.label.toLowerCase().includes(state.filterValue.toLowerCase());
}
})
.sort((a, b) => (state.sortRightDesc ? a.label.localeCompare(b.label) : b.label.localeCompare(a.label)));

const handleOptionsClick = (event, value) => handleOptionClick(event, value, leftValues, true, dispatch, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface InternalDualListSelectProps {
id?: string;
leftValues?: DualListOption[];
rightValues?: DualListOption[];
isFilterCaseInSensitive?: boolean;
FormFieldGridProps?: GridProps;
InternalGridProps?: GridProps;
ListGridProps?: GridProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ DualListSelect.propTypes = {
rightValues: PropTypes.array,
handleValuesClick: PropTypes.func,
isFilterable: PropTypes.bool,
isFilterCaseInSensitive: PropTypes.bool,
// props
FormFieldGridProps: PropTypes.object,
InternalGridProps: PropTypes.object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Dual list select is wrapped in a form group, so it accepts all [form group props
|filterOptionsText|String|'Remove your filter to see all options'|Placeholder for options when there is no filtered option|
|leftSortTitle|String|'Sort options'|Accessible title for left sort button.|
|rightSortTitle|String|'Sort value'|Accessible title for right sort button.|
|isFilterCaseInSensitive|bool|true|Toolbar filter is case insensitive|

### Options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Dual list select is wrapped in a form group, so it accepts all [form group props
|filterValueTitle|String|'Filter selected value'|Placeholder for value filter input|
|filterValueText|String|'Remove your filter to see all selected'|Placeholder for value when there is no filtered value|
|filterOptionsText|String|'Remove your filter to see all options'|Placeholder for options when there is no filtered option|
|isFilterCaseInSensitive|bool|true|Toolbar filter is case insensitive|

### Options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Dual list select is wrapped in a form group, so it accepts all [form group props
|filterOptionsText|String|'Remove your filter to see all options'|Placeholder for options when there is no filtered option|
|checkboxVariant|bool|false|Change list item to checkboxes|
|isFilterable|bool|true|Shows toolbar for both lists|
|isFilterCaseInSensitive|bool|true|Toolbar filter is case insensitive|

### Options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface InternalDualListSelectProps {
filterOptionsText?: ReactNode;
leftValues?: DualListSelectOption[];
rightValues?: DualListSelectOption[];
isFilterCaseInSensitive?: boolean;
/** Sub components customization API */
OptionsListProps?: SegmentProps;
OptionProps?: DualListSelectOptionProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ DualList.propTypes = {
validateOnMount: PropTypes.bool,
leftSortTitle: PropTypes.node,
rightSortTitle: PropTypes.node,
isFilterCaseInSensitive: PropTypes.bool,
/** Sub components customization API */
OptionsListProps: PropTypes.object,
OptionProps: PropTypes.object,
Expand Down
Loading