-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile] Add inserter block search #29169
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jhnstn! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Switch to useDispatch for insertDefaultBlock Switch to useDispatch for onSelect Switch to useDispatch for showInsertionPoint Remove withDispatch and WithSelect
Pass items to search results as a prop Move show/hide insertion point Move block insertion to menu Fix block insertion
Also re-org bottom sheet setup
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.
icon={ arrowLeft } | ||
onClick={ () => { | ||
inputRef.current.blur(); | ||
onChange( '' ); |
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.
Out of curiousity, why default to empty string instead of undefined?
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.
Good question, I was thinking the same when I looked back at this PR 😆 . After reviewing the changes as they are now I can't find an explicit reason. I believe as some point while I was drafting the changes I was treating undefined
differently. That's not the case now.
I might update the onChange
function definition to use ''
as the default value in a later change. That way the value remains a String
type but can be called with undefined
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.
Weird search is being handled in other PR. This one works well.
Yes, I noticed that too. The fix is in a lower level component which I didn't want to include in this new work. The trick is the fix is easier to verify with this change set. Here is the fix PR #29274 |
let itemsToDisplay = items.filter( | ||
( { name } ) => name !== 'core/block' | ||
); | ||
|
||
itemsToDisplay = searchItems( itemsToDisplay, filterValue ); |
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.
Minor thing, but I wonder if instead of using a let here we could used two const
variables with names that showed how they were different.
Description
Adds a block search form to the existing search menu. The available blocks are filtered according to the search query.
The search form is only rendered when a minimal number of blocks are available in the menu (the current min is set to 2)
The new feature is behind the
__DEV__
flag in this change set.Part of wordpress-mobile/gutenberg-mobile#2570
How has this been tested?
Testing search flow
Open the mobile block inserter
Press "Search blocks"
Try searching for a block with the soft keyboard
Try pressing on a block after searching
Press "Search blocks"
Try searching with a single character i.e,
i
Testing canceling search flows
Open the mobile block inserter
Press "Search blocks"
Press the arrow on the left side of the input
Press "Search blocks" again
Start searching for a block
Press the x on the right side of the input
Start searching for a block again
Press the arrow on the left side of the input
Press "Search blocks" again
Testing with few available blocks
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: