getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

Writer field: Cursor jumps when deleting a word in popup/drawer mode within a Layout field. #4789

Closed RomanWu closed 1 year ago

RomanWu commented 2 years ago

Description

When writing in a Writer field, going back in the text and deleting a word results in the cursor jumping to the end of the text. This happens only, when the field is used in a Layout and is opened in the popup/drawer by way of clicking on the pencil icon.

Expected behavior
The cursor should stay at the position, where the text is beeing edited.

To reproduce

  1. Add a Layout field
  2. In this Layout, add a Text-Block
  3. Edit this block in the popup/drawer by clicking the pencil
  4. Enter a sentence and try to delete a word in the middle of the sentence, using the Backspace-Key.

The cursor will jump to the end of the text, when all the characters of the word are deleted. (It seems to me possibly connected to the replacement of the two consecutive Space characters.)

This does not happen, when the text is edited directly in the Layout.

Screenshot

writer-issue-2

Your setup

Kirby Version
Kirby 3.8.0 Kirby 3.7.3

Your system (please complete the following information) Safari 15.6 MacOS Chrome 106 MacOS Firefox 105 MacOS

distantnative commented 1 year ago

I can reproduce the issue with Kirby 3.8.3 - though not always. Haven't spotted any pattern, seems to be quite randomly when it appears and when not (though it appears in a lot, 40-50% of the attempts).

RomanWu commented 1 year ago

I can always reproduce it in Kirby 3.8.3. The Writer field needs to be in a Layout. Then you need to open the Popup/Drawer by clicking the pencil. And if you then delete a word mid sentence (by way of multiple presses of the backspace key), then as soon as the word is gone, the cursor jumps to the end. Also, at the same moment, two consecutive space characters, that would have remained, are corrected to just one space. I have this behaviour in multiple browsers and consistently all the time.

The issue is most clear, when one tries to delete multiple words mid sentence. After the first word, the cursor jumps to the end.

RomanWu commented 1 year ago

I can reproduce the issue in Kirby 3.9.2.

rlb222 commented 1 year ago

I can reproduce the issue in combination with using markup signs (3.9.2). When I add a * somewhere in the middle of the text it will jump to the end. I see this happen in the notes from the starter kit. And also in blocks I added in my own site on the basis of this blocks cookbook page.

In this last instance I have the problem in the inline editing of a block and also in the open the Popup/Drawer.

I have tried to solve my issue: first I installed previous versions of Kirby, but no change. So I changed the code.

changed the preview to not-editable In the plugins/block-factory/index.js where the preview and editing of the blocks is described, I swapped the lines for

. Now the preview itself is not editable anymore. It solved the problem: I can edit the data in the popup drawer with no problems.

thanks, René

distantnative commented 1 year ago

This seems to be solved in Kirby 4 (layout field > text block > open drawer > type sentence > delete word in the middle of the sentence > cursor doesn't jump).

Please let me know if you can still reproduce it.