Skip to content

Backspace deletes all tabs instead of just previous tab #7

Open
@avk

Description

Steps to reproduce

  1. Start at the beginning of a line, with or without text.
  2. Insert 3 tabs via "Tab" key.
  3. Tap "Backspace" key.

Expected

  1. 2 tabs to remain on the current line.

Actual

  1. All tabs are deleted.

I'm not sure what I'm doing differently from the demo, where

  1. a tabbed line without text correctly deletes individual tabs, while
  2. a tabbed line with text deletes individual spaces (instead of tabs)

Here's my relevant code:

  handleKeyCommand(command) {
    let { editorState } = this.state;
    // enable deleting tab characters inserted by CodeUtils.handleTab
    // don't limit to code blocks
    let newState = CodeUtils.handleKeyCommand(editorState, command);
    if (newState) {
      this.setState({ editorState: newState });
      return true;
    }
    return false;
  }

  handleTab(evt) {
    this.setState({
      editorState: CodeUtils.handleTab(evt, this.state.editorState),
    });
  }

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

  render() {
    return (
      <div className="project-editor">
        <Editor 
          editorState={this.state.editorState}
          handleKeyCommand={this.handleKeyCommand}
          onChange={this.handleWrote}
          onTab={this.handleTab}
        />
      </div>
    );
  }

Have you seen this before? Any ideas?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions