Repository navigation
Refactor FlatTermSelector into a functional component - #33459
Conversation
|
Size Change: -333 B (0%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
93cf8a5 to
85f5b40
Compare
85f5b40 to
52a0a66
Compare
| } ) | ||
| .catch( ( error ) => { | ||
| const errorCode = error.code; | ||
| if ( errorCode === 'term_exists' ) { |
There was a problem hiding this comment.
What happens if we don't try to deal with the error at all, is it still necessary?
There was a problem hiding this comment.
I'm not 100% sure how useful this logic is for actual use-cases. The only way I can trigger an error is if I paster comma-separated list of tags - Existing, Existing Tag.
If a user starts typing and then hits enter, we already have that tag in the suggestions list most of the time. I will do another round of tests with slow network emulated.
| withSpokenMessages, | ||
| withFilters( 'editor.PostTaxonomyType' ) | ||
| )( FlatTermSelector ); | ||
| export default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector ); |
There was a problem hiding this comment.
Similar to the other PR, if we want to land this, we may need to check plugins using that hook and warning them.
getdave
left a comment
There was a problem hiding this comment.
Thanks for working on this 🎖️
I noticed a few UX things I wanted to raise.
Collapsing/Expanding on typing
Firstly, when typing at an "average" typing speed (as in the speed I might type when trying to remember the name of a tag) I noticed the list re-renders by completely "collapsing" and then expanding again to reveal nearly identical results. I wonder if there's a way to make it less visually jarring by perhaps retaining some kind of minimum result list height during the debounced request?
Screen.Capture.on.2021-08-09.at.17-34-03.1.mp4
Gray background appears when adding tag
When I added a tag a gray background appears on the entire control. Not sure if that's an intentional signal that some "saving" is happening but it caught my eye.
Screen.Capture.on.2021-08-09.at.17-34-39.mp4
Creating terms disappearing tag and gray background
When you create a tag using "ENTER" there is a point where the tag disappears entirely then re-appears after the gray background disappears. Easier to see in the video
Screen.Capture.on.2021-08-09.at.17-40-38.mp4
Slow network UX
When switching to a slow 3G network, these above issues are made worse. Best seen in the video. I think what we need is some improved loading/fetching states.
Screen.Capture.on.2021-08-09.at.17-47-43.mp4
Other than that this seems pretty close 🥳
|
@getdave, thanks for the detailed feedback ⭐ Collapsing/Expanding on typing Yeah, I need to fix this now or as a follow-up PR. The problem here is that Currently, I'm not sure how to solve this, but I will look into it. Gray background appears when adding tag It is caused by Creating terms disappearing tag This is a known issue with the component. It's a little more visible now that I don't use the local state for managing values. Creating tags "on the fly" using a comma or enter key has its problems; see #15406. Maybe we should add an input field + button for creating new tags. It would be similar to how the categories panel does it and Tags in the classic editor. @youknowriad what do you think? |
e591b86 to
28dc96d
Compare
|
I think tags disappearing while core data re-fetches updated list got a little worse after #34583, now that each It is the only remaining issue with refactoring, but it isn't very pleasant. So I'm looking into ways to use "derived" values while the selector is resolving. P.S. If we're already using a similar pattern in the core, please point me in that direction 🙇 |
28dc96d to
2bd9bfd
Compare
2bd9bfd to
da82875
Compare
|
Hi, @getdave I'm managed to resolve the "terms disappearing" issue. The solution (da82875) isn't elegant, but it works. The only remaining issue is "Collapsing/Expanding on typing," which can be addressed separately. I would appreciate another round of tests, and if you think this is in good shape to merge. |
getdave
left a comment
There was a problem hiding this comment.
I gave this another spin on emulated Slow 3G and I still noticed some unusual behaviour:
Screen.Capture.on.2021-10-12.at.13-46-44.mov
Not exactly sure what's going on but it looks like re-rendering whilst typing is still occurring.
I wonder if this is because we're re-rendering the entire list of tags when a tag has been saved and the resolver returns success?
Perhaps we could allow the user to add tag items but add some kind of visual cue to indicate whether they have been saved or not? That way when the tag is saved we just re-render that tag (to reflect the new "saved" state) but not all the tags.
So we are essentially allowing the user to add as many tags as they like visually, but only those which are visually marked as "saved" will be persisted.
|
Thanks for the feedback, @getdave.
That's correct. Also, in your screencast, we have to request resolved one by one, so we get this unusual behavior. @youknowriad, is there a way to cancel outgoing resolutions in the I don't think you can "mark" specific tokens in |
I don't think there is but conceptually speaking, I'm not sure that it should have any impact on components |
|
Thanks again for your feedback, @getdave, and @youknowriad. The newly created terms disappearing on slow connections is a known issue. See #13282 and #29077. Maybe we should fix that issue separately and keeps this PR purely refactoring one. What do you think? |
If it's a known bug and we're not introducing it here as a result of refactor then it should be ok to look to merge. But I'll defer to @youknowriad 🙇♂️ |
|
I won't have time to review deeply but if you're confident about it go for it 👍 |
|
I'm pretty confident, also shipping with the next Gutenberg version will give me some time to fix any issues I missed. |
|
@getdave, @youknowriad can I get ✅ on this PR? I'm confident refactoring isn't introducing any regression. However, I can do follow-up PRs for bug fixes during the 5.9 release cycle in the worst-case scenario. |
youknowriad
left a comment
There was a problem hiding this comment.
Let's give this a try. Thanks for all your work here.
Search is debounced now. I don't think there's a need for this limit anymore. Use also might use tags with two characters, like WP.
6c107bd to
b0a45fb
Compare
Feedback needs to be addressed separately.
Description
I tried refactoring the
findOrCreateTermfunction and use thesaveEntityRecordaction, but I cannot catch errors with action when the term already exits. I'm open to suggestions on this one 🙇Fixes #15147.
How has this been tested?
Create a post and check the following:
Types of changes
Enhancement
Checklist:
*.native.jsfiles for terms that need renaming or removal).