{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/draft-js/issues/228","repository_url":"https://api.github.com/repos/facebook/draft-js","labels_url":"https://api.github.com/repos/facebook/draft-js/issues/228/labels{/name}","comments_url":"https://api.github.com/repos/facebook/draft-js/issues/228/comments","events_url":"https://api.github.com/repos/facebook/draft-js/issues/228/events","html_url":"https://github.com/facebook/draft-js/issues/228","id":143057486,"number":228,"title":"Current inline styles are lost when block type is changed","user":{"login":"rnicholus","id":593312,"avatar_url":"https://avatars.githubusercontent.com/u/593312?v=3","gravatar_id":"","url":"https://api.github.com/users/rnicholus","html_url":"https://github.com/rnicholus","followers_url":"https://api.github.com/users/rnicholus/followers","following_url":"https://api.github.com/users/rnicholus/following{/other_user}","gists_url":"https://api.github.com/users/rnicholus/gists{/gist_id}","starred_url":"https://api.github.com/users/rnicholus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnicholus/subscriptions","organizations_url":"https://api.github.com/users/rnicholus/orgs","repos_url":"https://api.github.com/users/rnicholus/repos","events_url":"https://api.github.com/users/rnicholus/events{/privacy}","received_events_url":"https://api.github.com/users/rnicholus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/draft-js/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-23T19:28:39Z","updated_at":"2016-03-24T14:33:48Z","closed_at":null,"body":"I noticed this when integrating Draft.js into my own application. In my case, I was setting per-block alignment based on user input by changing the block type using `RichUtils.toggleBlockType`. When I do this, if there are any existing currently inline styles, they are lost.\r\n\r\nI can reproduce the same behavior on the [live Draft.js demo](https://facebook.github.io/draft-js/). Steps to reproduce:\r\n\r\n1. Click bold and or italic.\r\n2. Click the UL or H1 or BlockQuote button (or any other button that changes the block type). \r\n\r\nNotice the bold/italic style has been reverted. This does _not_ occur if you type some text in between steps 1 and 2. I attempted to trace the exact issue in the code, but due to my relative unfamiliarity with the codebase, I was unable to locate the specific bug or determine a suitable workaround. If you have any advice regarding a workaround, that would be most helpful.\r\n\r\nThanks much for a spectacular library!"},"comment":{"url":"https://api.github.com/repos/facebook/draft-js/issues/comments/200864026","html_url":"https://github.com/facebook/draft-js/issues/228#issuecomment-200864026","issue_url":"https://api.github.com/repos/facebook/draft-js/issues/228","id":200864026,"user":{"login":"rnicholus","id":593312,"avatar_url":"https://avatars.githubusercontent.com/u/593312?v=3","gravatar_id":"","url":"https://api.github.com/users/rnicholus","html_url":"https://github.com/rnicholus","followers_url":"https://api.github.com/users/rnicholus/followers","following_url":"https://api.github.com/users/rnicholus/following{/other_user}","gists_url":"https://api.github.com/users/rnicholus/gists{/gist_id}","starred_url":"https://api.github.com/users/rnicholus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnicholus/subscriptions","organizations_url":"https://api.github.com/users/rnicholus/orgs","repos_url":"https://api.github.com/users/rnicholus/repos","events_url":"https://api.github.com/users/rnicholus/events{/privacy}","received_events_url":"https://api.github.com/users/rnicholus/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T14:33:48Z","updated_at":"2016-03-24T14:33:48Z","body":">To clarify, are you selecting \"Bold\" while the cursor is in a collapsed (zero-character) state, then switching to H1?\r\n\r\nYes, that is correct. The same issue occurs when I select H2, H3, or any other button that changes the block type. \r\n\r\n> This could probably be avoided here if the EditorChangeType is 'change-block-type'.\r\n\r\nAdjustments to the push method of `EditorState` suggest that you are correct. Thanks for your help! I'll follow up with a pull request shortly."}}