Closed wobo-bledebur closed 1 year ago
Thanks for providing an example repo- I was able to recreate the issue as you described
Just a quick note, @viniciuspietscher and I happened to take a look at this last night and we think we see what's up.
The cause is likely this line:
$elements.callNativeMethod(doc, 'execCommand', 'insertText', nativeUI, text)
This is how characters are added into a contenteditable
element through cy.type()
, but the way execCommand
handles this seems to be to briefly turn on document.designMode
, which makes everything act like regular contenteditable
and presumably that overrides the intended behavior of the experimental plaintext-only
value.
I don't have a particular way forward to suggest, but wanted to share what we learned looking through the code so it can help the next person, or possibly this will help you create your own workaround for the time being.
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
This issue has been closed due to inactivity.
Current behavior
Given this element:
And this action:
The content of the element will be
FOO<div>BAR</div>
, which is the expected behavior whencontenteditable="true"
but not whencontenteditable="plaintext-only"
.Desired behavior
Given this action:
div#test
should have the following innerHTML content:Test code to reproduce
Forked repo with failing test case.
Note that if you manually type "FOO", "\<Enter>", "BAR" in the same Chrome window that the automated test had been running, you will get the expected behavior.
Cypress Version
9.5.3
Other
Technically,
content-editable="plaintext-only"
is considered experimental. But it is widely supported, is used by many existing libraries, and is often the only viable option for allowing multi-line plain text editing for cases when using a<textarea>
is not viable due to design requirements. So I wanted to appeal to you to possibly add support. Thank you!