Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Arrow keys trapped by block menu after typing / #259

Open
ca-shen98 opened this issue Sep 2, 2020 · 3 comments
Open

Arrow keys trapped by block menu after typing / #259

ca-shen98 opened this issue Sep 2, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@ca-shen98
Copy link

ca-shen98 commented Sep 2, 2020

I think this is due to the BlockMenuTrigger plugin's handleKeyDown prop. The AllSelection results in a from position of 0 and a parentOffset of 0, which means the textBetween call within the run function with arguments from=0, to=0 returns an empty string which is matched by the regex. I don't have a suggestion atm for fixing, but hopefully a minor change should be fine.

To Reproduce
Steps to reproduce the behavior:

  1. Do a select all within the editor.
  2. Press the up or down arrow key.
  3. Observe that the selection state does not change.

Expected behavior
I'd assume that this should cancel out of the selection.

@ca-shen98 ca-shen98 added the bug Something isn't working label Sep 2, 2020
@tommoor
Copy link
Member

tommoor commented Sep 2, 2020

It's not related to the BlockMenuTrigger, disabling that extension proves as much – in fact this seems to be just standard behavior of prosemirror, it's the same in the basic example here:
https://prosemirror.net/examples/basic/

I don't disagree though, when left + right remove the selection I would have thought up+down would be the same.

@tommoor
Copy link
Member

tommoor commented Sep 2, 2020

Give the attached PR a try.

@ca-shen98
Copy link
Author

Cool, that fix worked for the AllSelection case, thanks :) I was still playing around with the block menu and the up/down arrows though, and there's maybe? still some undesired behavior regardless of the select all behavior ...

Once the block menu opens on an empty block using the /... input, you can still leave the empty line using the left and right arrow keys, with the menu remaining open - then when you select an item from the menu, or do an enter key press, it inserts the block type after the currently selected line/node, not where the block menu was opened. I think my expected behavior for this scenario is that the menu closes once the cursor leaves the initial line.

Another thing is if I type out a string resulting in no results matching in the menu and press enter, closing the menu, or if I just close the menu with the esc key, I expect to be able to interact as normal with the lines, moving with the up/down arrow keys, and inserting new lines with the enter key, but the editor is preventing this from happening.

Zipped a screen recording that demonstrates - after typing "/has", I can't move off the line using up/down arrow or enter key presses.
Screen Recording.mov.zip

I was trying to see whether it's possible to check whether the blockmenu is open to here - https://github.com/outline/rich-markdown-editor/blob/develop/src/plugins/BlockMenuTrigger.ts#L14, but I'm not sure what the best way to share state through the Extension interface.

@tommoor tommoor closed this as completed in 4a7772f Sep 2, 2020
@tommoor tommoor reopened this Sep 2, 2020
@tommoor tommoor changed the title Up/down arrow keys after doing a select all does not cancel out of the selection. Arrow keys and block menu after typing / Sep 2, 2020
@tommoor tommoor changed the title Arrow keys and block menu after typing / Arrow keys trapped by block menu after typing / Sep 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants