Skip to content

refactor(favorites): one inline editor, used twice - #617

Merged
EVWorth merged 1 commit into
mainfrom
refactor/favorites-editing-hook
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
refactor/favorites-editing-hook

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 10, 2026

Copy link
Copy Markdown
Owner

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.

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 → 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.

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]>
@EVWorth
EVWorth merged commit 0f12a7c into main Sep 10, 2026
12 checks passed
@EVWorth
EVWorth deleted the refactor/favorites-editing-hook branch September 10, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1/arch] QueryFavorites.tsx 271 LOC with 8 useState hooks for transient UI state — should be a hook/store

1 participant