See related https://github.com/WordPress/gutenberg/issues/5592
Playing a bit with the Slash inserter, I was initially a bit puzzled by (what appeared to me) the lack of accuracy in the search results. Please see the screenshot below:
For example, typing /t
displays some results: most of them starts with t
but there are also: "Paragraph", "Heading", and "WordPress.tv".
Or, typing /i
displays also "Gallery", "Cover Image", and "Flickr".
In the first example, I was typing t
to search for the Table block, and I couldn't understand why the inserter was showing me also the Paragraph, the Heading, etc. It looked like an error to me.
Then, I realized block types have "aliases" (keywords) to make the search smarter. The Paragraph block has a text
keyword, the Heading has a title
keyword so they match the t
. However, WordPress.tv
doesn't have any keyword and I suspect the dot before tv
plays a role here.
Same for the /i
: Gallery has an images
keyword and Flickr has an image
keyword. However, Cover Image doesn't have any keyword and I suspect it matches the beginning of the second word (Image).
Regardless of the edge cases above, I'd tend to think the smart search based on keywords makes more sense in the Popover Inserter, but I'm not fully convinced it adds a value in the Slash inserter.
In this case, the Slash Inserter looks like sort of a menu: my focus instinctively goes to the first letter of the menu items and the search results that don't start with the letter I just typed look just wrong to me.
I'd suggest to consider to disable the keyword-based search in this specific instance of auto-completer and search just for the block name.
Re: one of the edge cases, seems the dot is really considered a word separator:
Suggestion to possibly sort items that come up in search via keywords second to matches of the actual block name first. So in the /t example the order could be: Twitter, TED, Tumblr, Table, Text Columns, Paragraph, Header, WordPress.tv. I do see benefit in including keyword matches in the results, just maybe having those appear second may help?
@jeffpaul that's certainly an option :) I'd suggest to try to fix the edge cases anyway (e.g. the dot, multiple words with space).
@afercia I actually think the edge cases are useful as I could see someone trying to remember "what was that something something dot com integration that I use for a block?" and being able to type in /com and see /Meetup.com would be useful. Same thing for multiple words with a space (e.g. Cover Image).
We could also make it so that aliases need exact matches (i.e. you have to type /text for paragraph to appear) or at least have to match >3 letters.
We could also make it so that the block name transforms to the alias if it's matching an alias (so it'd say "Text" instead of "Paragraph" next to the block).
+1 to Mat铆as suggestion. It is very nice/important to be able to search for aliases in the inserter and slash command, in the case of finding "Heading" when searching for /t is a matter of it also picking up "Title" which is a heading alias.
I also agree, having aliases is going to make this more magic for users. I like the idea of the block name transforming to the alias if it's matching one.
Related issue to search (not specifically the slash inserter, since I imagine search is the same for all insertion types):
It can be hard to find some blocks via search and should probably have more aliases, for example, the File
block.
Scenario: I want visitors to download an mp3 on my site, so I search for "download", "MP3", and "button", but none of those queries return the File block in the results. Download
and mp3
return nothing, and button
returns the button block, but afaik it doesn't have that download file functionality, it's just a link.
I would like this issue to get bumped to maybe normal
since I think it encompasses block searching in general.
@afercia, I believe the searching function and aliases have been worked on since the creation of this issue. I haven't noticed any issues searching myself, but wanted to check with you before closing this. Do you still find any problems?
I guess the algorithm improved a bit but maybe needs one more round of iteration. The point is it forces users to type more characters than needed.
As a user, I would like to type, for example, t
and get the most logical results in the first positions so I can just press Enter and I'm done. Instead, I'm forced to type more characters to get what I actually want or to use the arrow keys / mouse to select the block I need.
Some examples in the screenshot below:
t
because I want a table: I get a heading in the first position. Table is at the 7th position.b
for a button: I get a list. p
for pullquote: I get an Image (?) then a Gallery (?) then a file (??). Puzzling. Under the hood, the keywords are photo
, photos
, pdf
and that explains the match with the p
s
and I get a... heading (??) followed by a group (??). The involved keywords are subtitle
and section
There are way more examples. To me, it's an annoyance because I'd like to get as first results the ones that actually start with the character I typed. I'd like to suggest to review a bit how this works and give more "weight" to the results that have an actual match with the first letter of the main block name.
Let's bump priority of this one, it seems to have been getting worse. It might also make sense to reduce the number of matches, it looks a bit excessive.
Other issues for reference: #14868, #24651.
Most helpful comment
Related issue to search (not specifically the slash inserter, since I imagine search is the same for all insertion types):
It can be hard to find some blocks via search and should probably have more aliases, for example, the
File
block.Scenario: I want visitors to download an mp3 on my site, so I search for "download", "MP3", and "button", but none of those queries return the File block in the results.
Download
andmp3
return nothing, andbutton
returns the button block, but afaik it doesn't have that download file functionality, it's just a link.I would like this issue to get bumped to maybe
normal
since I think it encompasses block searching in general.