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

Should type in contenteditable div even if it has invisible child with contenteditable=false (#2205) #2222

Merged
merged 6 commits into from
Apr 12, 2018

Conversation

AlexKamaev
Copy link
Contributor

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 8f15bfe have failed. See details:

@AlexKamaev AlexKamaev force-pushed the gh-2205 branch 2 times, most recently from 9e4c057 to 5ec78da Compare March 16, 2018 09:27
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 5ec78da have failed. See details.

@AlexKamaev AlexKamaev force-pushed the gh-2205 branch 2 times, most recently from 027208c to 4cbb952 Compare March 16, 2018 11:16
@AlexKamaev AlexKamaev closed this Mar 16, 2018
@AlexKamaev AlexKamaev reopened this Mar 16, 2018
@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 4cbb952 have passed. See details:

@AlexKamaev AlexKamaev force-pushed the gh-2205 branch 2 times, most recently from d1885a9 to 2f19d9d Compare March 16, 2018 11:56
@AlexKamaev AlexKamaev closed this Mar 16, 2018
@AlexKamaev AlexKamaev reopened this Mar 16, 2018
@AlexKamaev AlexKamaev closed this Mar 16, 2018
@AlexKamaev AlexKamaev reopened this Mar 16, 2018
@DevExpress DevExpress deleted a comment from testcafe-build-bot Mar 16, 2018
@DevExpress DevExpress deleted a comment from testcafe-build-bot Mar 16, 2018
@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 2f19d9d have passed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 2f19d9d have passed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 2f19d9d have passed. See details:

@AlexKamaev AlexKamaev changed the title [WIP]Should type in contenteditable div even if it has invisible child with contenteditable=false (#2205) Should type in contenteditable div even if it has invisible child with contenteditable=false (#2205) Mar 16, 2018
@AlexKamaev
Copy link
Contributor Author

Here we use isDisplayNone instead of IsElementHidden, because the situation is possible when textNode is inside a div with height = 0 and width = 0. In this case text is still visible, so I think textNode should not be ignored

Copy link
Contributor

@AlexanderMoskovkin AlexanderMoskovkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check visibility:hidden too

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 5636020 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 5fe7023 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 00fc15b have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 00fc15b have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit aef9b68 have passed. See details:

@AlexKamaev
Copy link
Contributor Author

FPR

@AlexanderMoskovkin AlexanderMoskovkin requested review from helen-dikareva and removed request for AndreyBelym April 5, 2018 15:26
@AlexanderMoskovkin
Copy link
Contributor

/cc @helen-dikareva

Copy link
Collaborator

@helen-dikareva helen-dikareva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work)

function hasChildren (node) {
return node.childNodes && domUtils.getChildNodesLength(node.childNodes);
function getVisibleChildren (node) {
return arrayUtils.filter(node.childNodes, child => domUtils.isTextNode(child) || domUtils.isElementNode(child) && styleUtils.isElementVisible(child));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use isVisibleTextNode for textNodes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, by using getVisibleChilndren I need to ignore elements which has display:none or visibility:hidden

}

function hasVisibleChildren (node) {
return getVisibleChildren(node).length;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faster will be use arrayUtils.some(node.childNodes,.... To do it we need to extract predicate function from get Visible Children.

const selectableChildren = arrayUtils.filter(visibleChildren, child => isNodeSelectable(child));
const breakLineElements = arrayUtils.filter(visibleChildren, child => domUtils.getTagName(child) === 'br');

return selectableChildren.length ? includeDescendants : isContentEditableRoot || breakLineElements.length;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ussually simplify this type of ternary expression :isContentEditableRoot || breakLineElements.length


return el && get(el, 'visibility') === 'hidden';
var isVisibilityHiddenTextNode = function (textNode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have had styleUtils.isNotVisibleNode please check methods. Can we merge them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my purposes I use isElementVisible from hammerhead.js which fits to me. As for other methods from style.js, I've just noticed that isVisibilityHiddenTextNode does not check all ancestors, it looks strange. So I've added isVisibilityHiddenNode method which checks only visibility:hidden property and then I used this method in isVisibilityHiddenTextNode.
As for styleUtils.isNotVisibleNode it also looks really strange:

export function isNotVisibleNode (node) {
    return !domUtils.isRenderedNode(node) || isHiddenNode(node) || isVisibilityHiddenTextNode(node);
}

It checks visibility:hidden only if node is text.
I think we need to review all these methods and try to refactor them. But I would prefer to creafe the separate issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like isNotVisibleNode method has incorrect name, because it used only for text nodes

if (domUtils.isTextNode(el))
        return !styleUtils.isNotVisibleNode(el);

But the name doesn't contains info about that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to review all these methods and try to refactor them. But I would prefer to creafe the separate issue.

I agree with this, but please rename isNotVisibleNode -> isNotVisibleTextNode now. Don't you mind?

@AlexKamaev AlexKamaev closed this Apr 10, 2018
@AlexKamaev AlexKamaev reopened this Apr 10, 2018
@AlexKamaev AlexKamaev closed this Apr 11, 2018
@AlexKamaev AlexKamaev reopened this Apr 11, 2018
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit d474b5d have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit d474b5d have passed. See details:

@AlexKamaev
Copy link
Contributor Author

please review changes and comments

const visibleChildren = getVisibleChildren(node);
const isContentEditableRoot = !domUtils.isContentEditableElement(node.parentNode);
const selectableChildren = arrayUtils.filter(visibleChildren, child => isNodeSelectable(child));
const breakLineElements = arrayUtils.filter(visibleChildren, child => domUtils.getTagName(child) === 'br');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to find all br elements, so we can use arrayUtils.some here


return el && get(el, 'visibility') === 'hidden';
var isVisibilityHiddenTextNode = function (textNode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like isNotVisibleNode method has incorrect name, because it used only for text nodes

if (domUtils.isTextNode(el))
        return !styleUtils.isNotVisibleNode(el);

But the name doesn't contains info about that.


return el && get(el, 'visibility') === 'hidden';
var isVisibilityHiddenTextNode = function (textNode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to review all these methods and try to refactor them. But I would prefer to creafe the separate issue.

I agree with this, but please rename isNotVisibleNode -> isNotVisibleTextNode now. Don't you mind?

await t
.click(editor)
.typeText(editor, 'Hello')
.wait(1000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to wait? Can we increase selectorTimeout here?

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 36d29f7 have passed. See details:

const selectableChildren = arrayUtils.filter(visibleChildren, child => isNodeSelectable(child));
const hasBreakLineElements = arrayUtils.some(visibleChildren, child => domUtils.getTagName(child) === 'br');

if (selectableChildren.length)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add includeDescendants arg to hasSelectableChildren method and use it here

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 2524cdc have passed. See details:

@AlexKamaev AlexKamaev merged commit 0f83b12 into DevExpress:master Apr 12, 2018
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request 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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants