Repository navigation
refactor(favorites): one inline editor, used twice - #617
Merged
Merged
Conversation
QueryFavorites held five pieces of state and two refs for editing in place — twice over, once for renaming and once for the description — inline among everything else the panel does (#340). None of it is about favorites; it is the mechanics of an inline editor, and both copies had to get the same subtleties right independently. useInlineEdit owns them: Escape records an explicit cancel so a blur arriving afterwards is ignored, and a refused value keeps the editor open rather than closing as though the edit had taken. Both were learned in #333 and only one copy had them. 562 lines to 511, fourteen useState to nine. The rest of what this component does is real work, not state plumbing. Extracting it introduced a regression and then caught it, which is the part worth recording. The hook treats an empty draft as a cancel, because emptying a name and clicking away means "never mind". A description is the opposite: clearing it is the only way to remove one. The first version made that impossible, and the comment I wrote claimed it did not — nothing failed, because no test covered clearing a description. There is one now, verified to fail against the version without `allowEmpty`. Closes #340 Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #340.
QueryFavorites held five pieces of state and two refs for editing in place — twice over, once for renaming and once for the description — inline among everything else the panel does. None of it is about favorites; it's the mechanics of an inline editor, and both copies had to get the same subtleties right independently.
useInlineEditowns them: Escape records an explicit cancel so a blur arriving afterwards is ignored, and a refused value keeps the editor open rather than closing as though the edit had taken. Both were learned in #333, and only one copy had them.562 → 511 lines, 14 → 9
useState.The extraction introduced a regression and then caught it
This is the part worth reading. The hook treats an empty draft as a cancel, because emptying a name and clicking away means "never mind". A description is the opposite: clearing it is the only way to remove one.
The first version made that impossible — and the comment I'd written claimed it didn't. Nothing failed, because no test covered clearing a description. There's one now, verified to fail against the version without
allowEmpty.Verification
13 hook tests, 3 new component tests. Unit 2090, browser 297, 0 lint errors.