klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2k stars 295 forks source link

2.4.1 Deleting passage text deleted a passage #1226

Open hituro opened 2 years ago

hituro commented 2 years ago

Describe the bug.

While editing a passage I pressed delete to delete some text and additionally deleted a passage on the passage map.

Steps to reproduce:

The passage is deleted

Expected behavior:

The passage is not deleted

Additional context on this problem.

This may be a Harlowe specific issue, but I am not sure. In any format the passage stays selected while you are editing it, and I suspect that it's losing focus on the text area of the passage that causes the delete to then remove the passage. Without testing every action on every format, I can't be sure which ones lose focus and which do not.

Twine version number

2.4.1

Does this problem occur with the web version of Twine or the desktop app?

Desktop app

What operating system does this problem occur on?

macOS

If this problem is occurring with the web version of Twine, what browser does it occur on?

No response

Presubmission checklist

klembot commented 2 years ago

I tried following these steps and I couldn't reproduce the problem. For me, when I do this, the Tag button in the editor dialog gains keyboard focus (shows a blue ring around it). I'm not sure what the difference could be in what we are doing...

We use react-hotkeys-hook to handle the keyboard shortcut, which I don't know exactly how it handles things... but in general, hotkeys work when a text field is not in focus. So I agree, it sounds like this is focus related.

In the final step, do you see a blinking cursor anywhere when you press the Delete key?

(footnoting that you should be able to undo this deletion when it happens, but of course that's not a good solution)

AlyxMS commented 2 years ago

Can reproduce.

Though I did not do the change story format to Harlowe and type text in the newly created passage steps. Story format is Sugarcube so I don't think format matters.

Windows 10, desktop app, 2.4.1.

No blinking cursor anywhere after adding tag.

I guess one solution would be disallowing passage to be deleted when it's open.

hituro commented 2 years ago

I think it's clear that this happens when the passage editing field loses focus, which will generally be because a command does not restore focus after doing something.

Thinking about general solutions, maybe just disable the delete button when the selected passage has an editor open, similar to how it is disabled for Start in 2.5