twinejs icon indicating copy to clipboard operation
twinejs copied to clipboard

2.4.1 Deleting passage text deleted a passage

Open hituro opened this issue 2 years ago • 3 comments

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:

  • Create a new story
  • Set the format to Harlowe
  • Add a passage
  • Edit the passage, type some text
  • Add a tag from the toolbar (e.g. verbatim)
  • Press delete

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

  • [ ] I am interested in working on code that would fix this bug. (This is not required to submit a bug report.)
  • [X] I have done a search and believe that an issue does not already exist for this bug in the GitHub repository.
  • [X] I have read and agree to abide by this project's Code of Conduct.

hituro avatar Jul 28 '22 12:07 hituro

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)

klembot avatar Jul 30 '22 20:07 klembot

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.

AlyxMS avatar Aug 19 '22 04:08 AlyxMS

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

hituro avatar Aug 29 '22 11:08 hituro