-
Notifications
You must be signed in to change notification settings - Fork 674
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
Conversation
❌ Tests for the commit 8f15bfe have failed. See details: |
9e4c057
to
5ec78da
Compare
027208c
to
4cbb952
Compare
✅ Tests for the commit 4cbb952 have passed. See details: |
d1885a9
to
2f19d9d
Compare
✅ Tests for the commit 2f19d9d have passed. See details: |
✅ Tests for the commit 2f19d9d have passed. See details: |
✅ Tests for the commit 2f19d9d have passed. See details: |
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 |
There was a problem hiding this 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
❌ Tests for the commit 5636020 have failed. See details: |
❌ Tests for the commit 5fe7023 have failed. See details: |
…d with contenteditable=false(closes DevExpress#2205)
❌ Tests for the commit 00fc15b have failed. See details: |
❌ Tests for the commit 00fc15b have failed. See details: |
✅ Tests for the commit aef9b68 have passed. See details: |
FPR |
/cc @helen-dikareva |
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
src/client/core/utils/style.js
Outdated
|
||
return el && get(el, 'visibility') === 'hidden'; | ||
var isVisibilityHiddenTextNode = function (textNode) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
❌ Tests for the commit d474b5d have failed. See details: |
✅ Tests for the commit d474b5d have passed. See details: |
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'); |
There was a problem hiding this comment.
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
src/client/core/utils/style.js
Outdated
|
||
return el && get(el, 'visibility') === 'hidden'; | ||
var isVisibilityHiddenTextNode = function (textNode) { |
There was a problem hiding this comment.
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.
src/client/core/utils/style.js
Outdated
|
||
return el && get(el, 'visibility') === 'hidden'; | ||
var isVisibilityHiddenTextNode = function (textNode) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
✅ 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) |
There was a problem hiding this comment.
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
✅ Tests for the commit 2524cdc have passed. See details: |
…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
…