-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DataViews: extract search
from filters
#55722
Changes from all commits
151b203
a4c7a52
5625d57
23f5248
aaf2b14
4375be2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,12 @@ import { SearchControl } from '@wordpress/components'; | |
*/ | ||
import useDebouncedInput from '../../utils/use-debounced-input'; | ||
|
||
export default function TextFilter( { filter, view, onChangeView } ) { | ||
export default function TextFilter( { label, view, onChangeView } ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be renamed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, though didn't want to do it in this PR to make reviews easier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const [ search, setSearch, debouncedSearch ] = useDebouncedInput( | ||
view.filters[ filter.id ] | ||
view.search | ||
); | ||
useEffect( () => { | ||
setSearch( view.filters[ filter.id ] ); | ||
setSearch( view.search ); | ||
}, [ view ] ); | ||
const onChangeViewRef = useRef( onChangeView ); | ||
useEffect( () => { | ||
|
@@ -25,13 +25,10 @@ export default function TextFilter( { filter, view, onChangeView } ) { | |
onChangeViewRef.current( ( currentView ) => ( { | ||
...currentView, | ||
page: 1, | ||
filters: { | ||
...currentView.filters, | ||
[ filter.id ]: debouncedSearch, | ||
}, | ||
search: debouncedSearch, | ||
} ) ); | ||
}, [ debouncedSearch ] ); | ||
const searchLabel = filter?.name || __( 'Filter list' ); | ||
const searchLabel = label || __( 'Filter list' ); | ||
return ( | ||
<SearchControl | ||
onChange={ setSearch } | ||
|
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.
Do you think we need to have these props to start with?
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.
Those are actions consumers may need to do. Happy to remove them if you rather don't allow them for now.