-
Notifications
You must be signed in to change notification settings - Fork 144
Forward autocompleter
prop from CompareFilter
to Search
#6911
Conversation
Test that it renders the basic storybook example without throwing an error. Move `path` in Storybook's example to a parameter, to allow setting it in unit tests.
Allow, to use the `custom` type of search, previously it was complaining about lack of `autocompleter`, even though it was provided. Fixes: #6890
@@ -91,7 +91,7 @@ export class CompareFilter extends Component { | |||
} | |||
|
|||
render() { | |||
const { labels, type } = this.props; | |||
const { labels, type, autocompleter } = this.props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about changing this to searchAutocompleter
? That could make it more obvious that it is used by search.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then it would be inconsistent with type
which is also kind of searchType
:
/**
* Which type of autocompleter should be used in the Search
*/
type: PropTypes.string.isRequired,
/**
* The custom autocompleter to be forwarded to the `Search` component.
*/
autocompleter: PropTypes.object,
and changing type
would be a breaking change.
As mentioned above I was thinking of doing it another way around and provide all props together like:
searchProps: PropTypes.shape( {
placeholder: PropTypes.string,
type: PropTypes.string.isRequired,
autocompleter: PropTypes.object,
} ),
Or even accepting the entire component as a prop.
Personally, to keep the API and prop names consistent, I'd either:
- Leave it as is, or
- Group all search props together.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from my one comment, this works well and the code is good. Pre-approving. Thanks!
I'm merging it as is. |
…merce/woocommerce-admin#6911) - Forward `autocompleter` prop from `CompareFilter` to `Search`. Allow, to use the `custom` type of search, previously it was complaining about lack of `autocompleter`, even though it was provided. - Move `path` in Storybooks example to a parameter, to allow setting it in unit tests. - Add few tests for FilterPicker. - it renders the basic storybook example without throwing an error - it forwards `autocompleter` & `type` props Fixes: woocommerce/woocommerce-admin#6890
(Follow-up to #6880, to make `ReportFilters support custom Search)
Forward
autocompleter
prop fromCompareFilter
toSearch
.Allow, to use the
custom
type of search, previously it was complaining about lack ofautocompleter
, even though it was provided.Move
path
in Storybooks example to a parameter, to allow setting it in unit tests.Add few tests for FilterPicker.
autocompleter
&type
propsFixes: #6890
Needed for:242-gh-woocommerce/google-listings-and-ads
Accessibility
No new texts or animations were introduced, existing ones behave as before.
prefers-reduced-motion
Screenshots
Detailed test instructions:
CompareFilter
withtype="custom"
andautocompleter
Doubts: