-
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
[Block Library - Query]: Allow term addition from user case-insensitive input #31301
[Block Library - Query]: Allow term addition from user case-insensitive input #31301
Conversation
Size Change: +58 B (0%) Total Size: 1.3 MB
ℹ️ View Unchanged
|
Not a code review, but the PR solves the issue. |
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.
Pending a typo, looks good in terms of code. :)
packages/block-library/src/query/edit/query-inspector-controls.js
Outdated
Show resolved
Hide resolved
const termIds = Array.from( | ||
newTermValues.reduce( ( accumulator, termValue ) => { | ||
const termId = getTermIdByTermValue( | ||
terms.mapByName, | ||
termValue | ||
); | ||
if ( termId ) accumulator.add( termId ); | ||
return accumulator; | ||
}, new Set() ) | ||
); |
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.
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.
Interesting indeed... I'll have to look into this a bit in general, as I'm quite fond of reduce
😄
f8b3c66
to
3d4f31c
Compare
3d4f31c
to
af7ba55
Compare
Description
Resolves: #31258
Currently
FormTokenField
which is used inQuery
block for adding categories and tags, shows suggestions that are case insensitive. The actual addition though was performed by trying to find a case sensitive match and that resulted in not adding a term if the user pressedEnter
or tried to separate withcomma
.This PR adds an extra check for entered terms in a non case sensitive way, to better match user expectations. I tried to find a better place for this behavior in
FormTokenField
but it seemed as a more specific case and added in Query for now.Testing instructions
Query
block withinherit
set tofalse
andpost type
topost
, to be able to change the categories/tagscategories
field the category you created but in a case insensitive way (example if the category isapple
typeAPple
) and then pressEnter
or separate withcomma
.