Stop filter from matching invisible properties#800
Merged
Conversation
Closes GriddleGriddle#725. The previous `if (filterable === false)` condition meant that `filterable={false}` must be explicitly set on a ColumnDefinition in order for any property returned by row.keySeq() to be ignored. This resulted in the filter matching invisible row properties such as griddleKey and any properties in the data not covered by a ColumnDefinition. I confirmed this by locally changing the expression at the end of this filter from: return value && value.toString().toLowerCase().indexOf(filterToLower) > -1; to: if (value && value.toString().toLowerCase().indexOf(filterToLower) > -1) { console.log('KEY:', key, 'VALUE:', value.toString().toLowerCase()); return true; } return false; and observed the unexpected filter matches on invisible row properties in the console. This fixes the problem by updating the condition to exclude griddleKey and any values not covered by a ColumnDefinition if any ColumnDefinitions are present. I've added new tests and validated the filter behavior in the Storybook. Bear in mind that columns corresponding to other React components may still match the filter based on generated HTML properties rendered as part of the value.toString().toLowerCase() expression. At this point the best course of action may be to recommend that such ColumnDefinitions are tagged with `filterable={false}` if it's a significant problem for the user.
Contributor
|
💯 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Griddle major version
1
Changes proposed in this pull request
Closes #725. This fixes the problem of invisible fields getting matched by the filter by updating the filteredDataSelector() condition to exclude griddleKey and any values not covered by a ColumnDefinition if any ColumnDefinitions are present.
Bear in mind that columns corresponding to other React components may still match the filter based on generated HTML properties rendered as part of the value.toString().toLowerCase() expression. At this point the best course of action may be to recommend that such ColumnDefinitions are tagged with
filterable={false}if it's a significant problem for the user.Why these changes are made
The previous
if (filterable === false)condition meant thatfilterable={false}must be explicitly set on a ColumnDefinition in order for any property returned by row.keySeq() to be ignored. This resulted in the filter matching invisible row properties such as griddleKey and any properties in the data not covered by a ColumnDefinition.I confirmed this by locally changing the expression at the end of this filter from:
to:
and observed the unexpected filter matches on invisible row properties in the console.
Are there tests?
I've added updated existing tests, added new tests, and validated the filter behavior in the Storybook.