Repository navigation
Conversation
When the last line of the composition input becomes empty (for example after pressing backspace on the only character of that line), Chromium inserts a trailing <br> as a placeholder so the empty line stays rendered. handleChange() removed every <br>, which left a text ending in a single "\n" with no placeholder. With white-space: pre-wrap such a trailing newline is not rendered as an empty line, so the line seemed to be deleted and the caret jumped to the end of the previous line. Replace a trailing <br> that follows a text node ending in "\n" with a "\n" text node instead of deleting it. This is the same placeholder Chromium already inserts when pressing enter at the end of the input (the draft then ends in "\n\n"). Any other <br> is still removed. Fixes session-foundation#2040 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
First time contributor checklist:
Contributor checklist:
devbranchpnpm readyrun passes successfully (I ranprettier --check,eslinton the changed file andtsc --noEmit, all clean; I did not run the fullpnpm test)Description
Fixes #2040.
When the last line of the composition input becomes empty (for example by pressing backspace on the only character of that line, or on the first character of a trailing line after lines were added with ctrl+enter), the line seemed to be deleted and the caret jumped to the end of the previous line.
Cause: in that case Chromium inserts a trailing
<br>as a placeholder so the empty last line stays rendered.handleChange()inCompositionInput.tsxremoved every<br>. What remained was a text ending in a single\nwithout a placeholder, whichwhite-space: pre-wrapdoes not render as an empty line.Fix: a trailing
<br>that follows a text node ending in\nis now replaced by a\ntext node instead of being deleted. This is the same placeholder Chromium already inserts when pressing enter at the end of the input (the draft then ends in\n\n, which is why sending trims trailing newlines). Any other<br>is still removed.Testing:
aaa, newline,b, newline,c) and pressed backspace on the last line. Before the fix the empty line vanished and the caret jumped up (confirmed with debug logging:onInputsaw"…\n<br>"andhandleChangeremoved the<br>). After the fix the empty line stays and the caret stays on it.