Skip to content

Fix draft title truncated to one line when opened from sidebar#237

Merged
oandregal merged 1 commit into
trunkfrom
pedantic-pare-452a50
May 21, 2026
Merged

Fix draft title truncated to one line when opened from sidebar#237
oandregal merged 1 commit into
trunkfrom
pedantic-pare-452a50

Conversation

@oandregal
Copy link
Copy Markdown
Contributor

Summary

  • Bug: Opening a draft from the sidebar sometimes shows the title cut off to a single line instead of wrapping. Navigating away and back restores correct wrapping.
  • Root cause: The title <textarea> height-calc useEffect only depended on titleInput. The textarea is conditionally rendered (only when state.status === 'ready'), but titleInput is initialized from the title prop while status is still 'loading'. When the async load completes, setTitleInput(result.title) is the same string — React sees no dep change, the effect never re-fires, and the textarea stays at rows={1}.
  • Fix: Added state.status to the effect's dependency array so the height calc re-runs when the textarea enters the DOM.

Test plan

  • Open a draft with a long title from the sidebar — title should wrap immediately
  • Edit the title to be longer/shorter — height should still auto-adjust
  • Switch between drafts rapidly — title should always render at correct height

🤖 Generated with Claude Code

The title textarea height-calc effect depended only on `titleInput`.
When opening a draft, `titleInput` is initialised from the `title` prop
while the textarea is still unmounted (status='loading'). Once the async
load completes, `setTitleInput(result.title)` is usually the same string
— React sees no dep change, the effect never re-fires, and the textarea
stays at `rows={1}`.

Adding `state.status` to the dep array ensures the effect runs when the
textarea enters the DOM (status changes to 'ready').

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 15:15
@oandregal oandregal merged commit e88bcb2 into trunk May 21, 2026
1 check failed
@oandregal oandregal deleted the pedantic-pare-452a50 branch May 21, 2026 15:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Draft Editor UI rendering bug where long draft titles could remain visually truncated to a single line when opening a draft from the sidebar, due to the title textarea auto-height effect not re-running when the editor transitions from loading to ready.

Changes:

  • Update the title textarea height-adjustment useEffect dependencies to include state.status, ensuring the effect re-runs when the textarea is conditionally mounted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants