Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot type into ProseMirror editor with placeholder #2205

Closed
tamlyn opened this issue Mar 8, 2018 · 6 comments
Closed

Cannot type into ProseMirror editor with placeholder #2205

tamlyn opened this issue Mar 8, 2018 · 6 comments
Assignees
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@tamlyn
Copy link

tamlyn commented Mar 8, 2018

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

Using typeText in an editor with a placeholder doesn't work (no text is entered).

What is the expected behavior?

Manually interacting with the editor works as expected and I would expect TestCafe to behave the same.

How would you reproduce the current behavior (if this is a bug)?

Here's a repro repo https://github.com/tamlyn/prosecafe

Specify your

  • operating system: MacOS 10.11
  • testcafe version: 0.19
  • node.js version: 8.9
  • browsers: chrome and firefox
@hdorgeval
Copy link

Hi @tamlyn, I have refactored your code in the repo (see the PR).
@AlexanderMoskovkin : is there a better way to solve this case?

@AlexKamaev
Copy link
Contributor

Hi @tamlyn @hdorgeval
I found that the ProseMirror editor contains this markup inside

<div class="placeholder ProseMirror-widget" contenteditable="false">Type here...</div>

When testcafe performs the type action, it checks an element's 'contenteditable' attribute. For this reason, it does not work as expected.
I recommend using @hdorgeval 's solution or take a look at my workaround based on hdorgeval's one. See the listing below:

test('empty editor with placeholder', async t => {
  const selector = Selector('#with-placeholder div[contenteditable]');
  await t
    await typeTextInEditor(selector, "Hello World", t);
    await t.expect(selector.innerText).contains('Hello');
})

async function typeTextInEditor(selector, text, t) {
  await goToEditMode(selector.find('p'));
  await t.typeText(selector, text, { replace : true });
}

const goToEditMode = ClientFunction(selector => {
    selector().innerHTML += '_';
});

In this case, we update the element's inner text in this function:

goToEditMode function

and the Prose editor removes div with the contenteditable='false' attribute, so that you can use our type action.

@tamlyn
Copy link
Author

tamlyn commented Mar 12, 2018

Thank you both for the rapid response and suggested workarounds. I don't think reaching into the DOM and manipulating innerHTML is a very robust long term solution. Could you help me understand why focusing the contenteditable=true div doesn't hide the placeholder as one would expect?

@AlexKamaev AlexKamaev reopened this Mar 13, 2018
@tamlyn
Copy link
Author

tamlyn commented Mar 13, 2018

I noticed yesterday that just appending an empty string to innerHTML is enough to make it editable:

selector().innerHTML += '';

@AlexKamaev
Copy link
Contributor

Could you help me understand why focusing the contenteditable=true div doesn't hide the placeholder as one would expect?

To hide a placeholder, it's required to click on the selector before typing.
So I think the correct version of the test should be the following:

test('empty editor with placeholder', async t => {
  const selector = Selector('#with-placeholder div[contenteditable]');
  await t
    await t.click(selector);
    await t.typeText(selector, 'Hellow world', { replace : true });
    await t.expect(selector.innerText).contains('Hello');
})

After the click placeholder is hidden as expected, however the test failed, so this behavior is incorrect and should be fixed.

@AlexKamaev AlexKamaev self-assigned this Mar 13, 2018
@AlexKamaev AlexKamaev added the TYPE: bug The described behavior is considered as wrong (bug). label Mar 13, 2018
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Mar 16, 2018
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Mar 16, 2018
AlexKamaev pushed a commit to AlexKamaev/testcafe that referenced this issue Mar 16, 2018
AlexKamaev pushed a commit to AlexKamaev/testcafe that referenced this issue Mar 16, 2018
AlexKamaev pushed a commit to AlexKamaev/testcafe that referenced this issue Mar 16, 2018
AlexKamaev pushed a commit to AlexKamaev/testcafe that referenced this issue Mar 16, 2018
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Mar 23, 2018
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Mar 27, 2018
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Mar 30, 2018
@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
…h contenteditable=false (DevExpress#2205) (DevExpress#2222)

* [WIP]Should type in contenteditable div even if it has invisible child with contenteditable=false(closes DevExpress#2205)

* add one more test case

* fix tests on safari osx

* fix changes after request

* fixes after review

* refactoring
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants