Skip to content
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

New block should reset inline styles #19

Open
sstur opened this issue Mar 21, 2016 · 3 comments
Open

New block should reset inline styles #19

sstur opened this issue Mar 21, 2016 · 3 comments
Labels

Comments

@sstur
Copy link
Owner

sstur commented Mar 21, 2016

If you set bold/italic/etc, type some text and then press enter to start a new paragraph, the style should be back to normal in the new block.

Thanks to @codesoda for noticing this bug.

@sstur sstur added the bug label Mar 21, 2016
@joepio
Copy link

joepio commented Apr 15, 2016

I don't think this is a bug, since the current behavior is what most users will expect. The Draft.js team at Facebook chose this behavior, since most text editors (such as Microsoft Word and Pages) use it as well.

I suggest adding an optional resetOnNewline setting that defaults to the current behavior.

@sstur
Copy link
Owner Author

sstur commented Apr 16, 2016

I've found this is what some users expect but others expect the opposite. Especially with some inline styles, like code/monospace, users expect insertion of a new block to signify they are done writing that snippet of code.

In my own research, I've found that editors who treat a return more like a line break (Word, Pages, Draft demo) do not tend to reset inline styles. But editors which have clear paragraph blocks, like Quip, give you a fresh start when you start a fresh block. When using Quip users find this behavior intuitive, but admittedly this is far less common than the MSWord behavior.

It sounds reasonable to make an option for this, but I'd like, by default, to reset inline styles for a new block for a few reasons:

  • I can think of far less use cases where you'd want to keep the inline styles of your previous block, and far more cases where you'd want to start a fresh block in a normal state. I think it's important in UX to do what users expect, but equally important to make the user's life easy by requiring less clicks for the most common cases.
  • There are well-known keystrokes for some inline styles (bold/italic) that users might use to manually turn off the style when they don't want it in a new block. But others (inline code) do not have well-known keyboard shortcuts so it would require the user to reach for the mouse in the more common case of wanting a clean new block.
  • When thinking about Word, Pages and Quip from a UX perspective, I'm far more inclined to model my work after Quip, which I think is amazing and modern, than the more traditional products of the last decade.

From a technical standpoint, I've checked into it and there are some complications that will make this a little difficult to solve. But I do think solving it is the right thing to do.

@joepio
Copy link

joepio commented Apr 16, 2016

I must say you make a compelling argument, and I personally find the reset on newline behavior preferable.

FYI: There has been some discussion on this topic in the Draft.js repo as well, where somebody suggested using a handleReturn prop function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants