Skip to content

Conversation

makenova
Copy link
Contributor

@makenova makenova commented Feb 1, 2018

For issue #189

Copy link
Member

@AllenFang AllenFang left a comment

Choose a reason for hiding this comment

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

@makenova how about we make it configurable ?! Keep current behavior as default and add case insensitive props, if ok, I can show you how to change or I can handle it, thanks

return cellStr === filterVal;
}
return cellStr.indexOf(filterVal) > -1;
const re = RegExp(filterVal, 'i');
Copy link
Member

Choose a reason for hiding this comment

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

is that danger? for example \test\ or \\test\\, maybe throw some err?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like if the filterVal is \test\?
I’ll do some testing to see if that can cause an error.

Copy link
Member

@AllenFang AllenFang Feb 3, 2018

Choose a reason for hiding this comment

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

yes, thanks !!

@makenova
Copy link
Contributor Author

makenova commented Feb 1, 2018

Making it configureable is a great idea!
Pls show me how you’d like it changed.

@AllenFang
Copy link
Member

AllenFang commented Feb 3, 2018

@makenova I think we can allow the text filter to have caseInsensitive via textFilter props.
Currently, text and select filter allow user to configure some thing, check this example, I think you can have the same way to do it.

add a new caseSensitive props for text filter
then on here get caseSensitive props, for example:

else {
        // select default comparator is EQ, others are LIKE
        const { comparator = (filterType === FILTER_TYPE.SELECT ? EQ : LIKE) } = filter.props;
        const caseSensitive = filter.props.caseSensitive || false;
        currFilters[dataField] = { filterVal, filterType, comparator, caseSensitive };
}
store.filters = currFilters;

then in https://github.com/react-bootstrap-table/react-bootstrap-table2/blob/master/packages/react-bootstrap-table2-filter/src/filter.js#L19, depends on the caseSensitive value to filter data.

Let me know if you got any question, thank you

@makenova
Copy link
Contributor Author

makenova commented Feb 5, 2018

I've updated it with caseSensitive props and moved away for using RegExp.

Copy link
Member

@AllenFang AllenFang left a comment

Choose a reason for hiding this comment

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

LGTM

@AllenFang AllenFang merged commit 65a596a into react-bootstrap-table:develop Feb 10, 2018
@AllenFang
Copy link
Member

@makenova thanks your contribution 👍

@AllenFang
Copy link
Member

AllenFang commented Feb 10, 2018

#201 . @makenova

@makenova makenova deleted the case-insensitive-text-filter branch March 14, 2018 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants