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

Inserting spaces in middle of "mention" (hashtag) breaks oddly #799

Open
benjie opened this issue Nov 19, 2020 · 0 comments
Open

Inserting spaces in middle of "mention" (hashtag) breaks oddly #799

benjie opened this issue Nov 19, 2020 · 0 comments
Assignees
Labels
status: confirmed 🟢 The bug has been tested and confirmed. status: sponsored 💖 All issues and pull requests which have been requested from or created by sponsors. type: bug 🪲 Something isn't working

Comments

@benjie
Copy link
Member

benjie commented Nov 19, 2020

Summary

Highlighting seems to go wrong in the mention extension when inserting spaces in the middle of a mention.

Steps to reproduce

Enter the following into playground, then click in the middle of the "oooo" and press spacebar once, and then again.

{
  "doc": {
    "type": "doc",
    "content": [
      {
        "type": "paragraph",
        "content": [
          {
            "type": "text",
            "text": "sdfsdfsdf #foooooo"
          }
        ]
      }
    ]
  },
  "playground": {
    "m": 1,
    "c": "import { useRemirrorPlayground } from \"@remirror/playground\";\nimport React, { FC } from \"react\";\nimport { MentionExtension } from \"remirror/extension/mention\";\nimport { RemirrorProvider, useManager, useRemirror } from \"remirror/react\";\n\nconst EXTENSIONS = () => [  new MentionExtension({\n    appendText: \" \",\n    matchers: [{ char: \"#\", name: \"tag\" }],\n  }),\n];\n\n/**\n * This component contains the editor and any toolbars/chrome it requires.\n */\nconst SmallEditor: FC = () => {\n  const { getRootProps } = useRemirror();\n\n  return (\n    <div>\n      <div {...getRootProps()} />\n    </div>\n  );\n};\n\nconst SmallEditorContainer = () => {\n  const extensionManager = useManager(EXTENSIONS);\n\n  const { value, onChange } = useRemirrorPlayground(extensionManager); // Delete this line\n\n  return (\n    <RemirrorProvider\n      manager={extensionManager}\n      value={value}\n      onChange={onChange}\n    >\n      <SmallEditor />\n    </RemirrorProvider>\n  );\n};\n\nexport default SmallEditorContainer;\n"
  }
}

Expected results

With square brackets [] representing highlighting (blue):

After one space:
sdfsdfsdf [#fooo] ooo

After two spaces:
sdfsdfsdf [#fooo] ooo

Actual results

After one space:
sdfsdfsdf [#fooo] [oo]o

After two spaces:
sdfsdfsdf #fooo ooo

@benjie benjie added the type: bug 🪲 Something isn't working label Nov 19, 2020
@ifiokjr ifiokjr added the status: confirmed 🟢 The bug has been tested and confirmed. label Nov 20, 2020
@ifiokjr ifiokjr self-assigned this Nov 20, 2020
@ifiokjr ifiokjr added the status: sponsored 💖 All issues and pull requests which have been requested from or created by sponsors. label Jan 8, 2021
@ifiokjr ifiokjr added this to To do in remirror@1.0.0 via automation Jan 8, 2021
@ifiokjr ifiokjr added this to Needs triage in Bugs via automation Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed 🟢 The bug has been tested and confirmed. status: sponsored 💖 All issues and pull requests which have been requested from or created by sponsors. type: bug 🪲 Something isn't working
Projects
Bugs
  
Needs triage
remirror@1.0.0
  
To do
Development

No branches or pull requests

2 participants