-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: Allow title to split onto multiple lines #4826
Conversation
autoFocus={ isNew && ! isMobile() } | ||
value={ post ? post.title : '' } | ||
aria-label={ this.translate( 'Edit title' ) } | ||
ref="titleInput" /> | ||
ref="titleInput" | ||
rows="1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the rows
default is 2
(reference)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I mean the default initial value for the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I mean the default initial value for the component.
Still not certain I'm following, but an empty field will default to 1
rows, and grow as necessary via autosize
. Or are you suggesting we use rows="1"
as a default prop for <TextareaAutosize />
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know what the prop meant just by looking at it :)
This is great, thanks for looking at it after I complained :) It works well for me, and I wouldn't mind merging before #4824 if that may take longer. |
@@ -1,10 +1,6 @@ | |||
.editor-title { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything we could simplify markup-wise here? Some of these nested elements were needed for correctly rendering the fade effect, which we don't need anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything we could simplify markup-wise here?
We'll likely need the relative wrapper for the loading block still, but I'll make another pass to be certain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the loading block :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the loading block :)
One PR at a time 😄
I want to do some last-minute performance debugging, as I was noticing an input lag in my testing. I think it may be that both the |
1c4e06c
to
3a15418
Compare
This was not previously accounting for newlines, added either by enter keypress or pasted text including multiple lines. Both cases are now accounted for in 99d89b1. Flipping this back to Needs Review. |
} ); | ||
const { isNew, site } = this.props; | ||
if ( ( isNew && ! prevProps.isNew ) || | ||
( isNew && get( prevProps.site, 'ID' ) !== get( site, 'ID' ) ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this indentation style is clearer here:
if (
( isNew && ! prevProps.isNew ) ||
( isNew && get( prevProps.site, 'ID' ) !== get( site, 'ID' ) )
) {
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this indentation style is clearer here:
I go back and forth myself, but FWIW this is the documented style:
Works on Chrome, Safari, Firefox, Edge. Code looks good. There are a couple of minor issues on IE11:
On iOS, I'm not able to paste because the text toolbar disappears immediately (also broken in master -> #4905), but other than that, the multi-line behavior seems fine. |
@nylen : Thanks for the review. Both issues should be fixed now. Neither solutions are pretty 😄 (692ecda, cab2d16). I'm still not entirely happy with the performance of the input with these changes. I've confirmed that the update calculations aren't being performed multiple times, but it still doesn't feel quite right. I think it's likely a combination of both the height calculation and the title saving its changes directly to the post store on each change. I'd like to move away from the latter case, but I think there are UX implications of having the option to "Save" changes as soon as characters are entered into the title field. |
👍 |
OK to merge? Waiting on anything? (5 days ago.) |
@lancewillett Works but not very happy with performance. Would be curious to get more feedback on whether it's noticeable, or at least spend more time profiling / improving performance before merging (as mentioned above, may require parallel changes to how we're tracking post title state). |
fwiw, I didn't notice any performance problems specific to this change. The editor was pretty laggy in my IE11 VM, but that was a general issue and also true in master. |
I'm marking as "In Progress" so it doesn't look like it's ready to merge by anyone. |
Updated original comment to reflect that this incidentally fixes #1679. |
Hi @aduth — checking in on this one since last update was about a month ago. Still in progress? Can we help test a branch or change to nudge it ahead? |
Paste behavior and Safari resize behavior look good now. I couldn't think of an easy way to address the undo stack issues either, so I'll file a separate issue for that. Also noting that when this change is merged it becomes more important to address the remaining issues with toolbar pinning (#4907) because this adds another situation where the height of editor elements above the toolbar can change. |
@aduth Did this fall through the cracks? Looks like it's been marked as ready to merge for awhile and the blocking PR is now resolved. |
@codebykat : Sorta. I had planned to coordinate this merging with #5445, the other being quite a bit more risky. It doesn't need to, though might benefit from some of the changes there. In any case, I can plan to revive and merge this one this week (looks to not have any merge conflicts surprisingly, but definitely warrants a rebase all the same). |
Either way! I was just going through my list and it looked abandoned. |
7363c63
to
1213941
Compare
Pushed a rebase including a much simpler technique for blocking newlines from pasted text. Because the title is a controlled input, we can replace the newlines in the See 1213941 for detail. I kept the |
padding-left: 10px; /* Intentionally non-standard to align editor body margin (10px) */ | ||
padding-right: 10px; | ||
border: none; | ||
font-family: $serif; | ||
font-size: 28px; | ||
color: $gray-dark; | ||
font-weight: 600; | ||
resize: none; | ||
-ms-overflow-y: hidden !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in IE when this rule isn't here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An ugly Windows native scrollbar, IIRC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An ugly Windows native scrollbar, IIRC.
Indeed, this one: #4826 (comment)
Clicking into the main editor does not deselect any selected title text |
I left a few notes on minor corner cases, but this feels pretty solid to me. 👍 |
Ah, this looks to be the same underlying cause as the issue with Enter I described above.
I'll plan to poke a bit to see if it's straight-forward to track when the input value could change in this way and whether adding a manual height recalculation could help (and to remove the |
1213941
to
66ad418
Compare
I came up with an alternate solution in 66ad418 to correct the autosize height after replacing if value would have stayed the same. This also removes the need for the Also rebased and squashed a bit, bumped version of |
Blocked by #4824Closes #1059
Fixes #1679
This pull request seeks to allow the editor post title to split onto multiple lines, rather than obscuring it with a long-content fade when the input loses focus.
It also introduces a new
<TextareaAutosize />
component to serve as a drop-in replacement for<textarea />
in order to facilitate in this use-case.Implementation notes:
While the implementation does use
autosize
, a third-party library, note that this is already used in the editor for the HTML editing tab, so the change in editor bundle size should be negligible if anything. A follow-up task may be to consider whether the HTML tab textarea can be updated to use this component instead.Testing instructions:
Verify in a large and small viewport size that the editor title resizes to accommodate multiple lines as needed. Ensure that existing behavior remains unaffected (notably, focusing the input for a new post, including when navigating from an existing post to a new post).