Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

[Chrome] Issue when inserting space as the last character #85

Closed
cgestes opened this issue Feb 25, 2016 · 2 comments
Closed

[Chrome] Issue when inserting space as the last character #85

cgestes opened this issue Feb 25, 2016 · 2 comments

Comments

@cgestes
Copy link
Contributor

cgestes commented Feb 25, 2016

When inserting a final space, the space is dropped, and when manually enterring text at the end, the enterred character is inserted after the cursor.

The following code reproduce the issue:

class MySpaceTestEditor extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      editorState: EditorState.createEmpty(),
    };
  }

  onChange = (editorState) => {
    this.setState({editorState});
  };

  onAdd = (value) => {
    let editorState = this.state.editorState;
    let contentState = editorState.getCurrentContent();

    contentState = Modifier.replaceText(
      contentState,
      contentState.getSelectionAfter(),
      ', ',
      editorState.getCurrentInlineStyle(),
      null,
    );
    editorState = EditorState.push(editorState, contentState, 'add-coma');

    this.setState({editorState: editorState});
  };

  render() {
    const {editorState} = this.state;
    return (
      <div>
        <Editor
          editorState={editorState}
          onChange={this.onChange}
        />
      <input
          onClick={this.onAdd}
          type="button"
          value="Test"
      />
    </div>
    );
  }
@cgestes cgestes changed the title Issue when inserting space as the last character [Chrome] Issue when inserting space as the last character Feb 25, 2016
@cgestes
Copy link
Contributor Author

cgestes commented Feb 25, 2016

The code works in Firefox, the issue is only visible in Chrome.

@cgestes
Copy link
Contributor Author

cgestes commented Feb 25, 2016

My bad.. I was not including Draft.css.

@cgestes cgestes closed this as completed Feb 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant