-
Notifications
You must be signed in to change notification settings - Fork 791
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
fix(color-contrast): correctly handle flex and position #4086
Conversation
return stackingOrder; | ||
} | ||
// since many things can create a new stacking context without position or |
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.
This is a nice change, I think your update including the nodeIndex
in the comparator is much cleaner than the old way.
lib/commons/dom/create-grid.js
Outdated
if (index !== -1) { | ||
stackingOrder.splice(index, stackingOrder.length - index); | ||
if (isStackingContext(vNode, parentVNode)) { | ||
const index = stackingOrder.findIndex(({ value }) => |
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.
Please don't have two variables with the same name in one function. This code is complicated enough 😁
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.
Thoughts on a separate PR enabling the no-shadow
eslint rule to catch this sort of issue proactively? (111 pre-existing issues, not trivial but manageable)
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.
Please
if (!isStackingContext(vNode, parentVNode)) { | ||
if (vNode.getComputedStylePropertyValue('position') !== 'static') { | ||
// Put positioned elements above floated elements | ||
stackingOrder.push(createContext(POSITION_STATIC_ORDER, vNode)); |
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.
Wow, did we call the position for when something's NOT static the POSITION_STATIC_ORDER
. Whoops! 🙄 That was my idea too wasn't it?
* @param {Number} stackLevel - The stack level of the stacking context | ||
* @param {Number} treeOrder - The elements depth-first traversal order | ||
* @param {VirtualNode} vNode - The virtual node that is the container for the stacking context |
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.
Thank you!
Mostly it's rearranging the order of the
createStackingContext
function to handle elements that created stacking context and needed to be positioned or floated. The code didn't handle elements that were both positioned withz-index: auto
and another property that made it a stacking context (likedisplay: flex
).Also changed how to handle adding the node index to every context by making it it's own property instead of combining it with the stacking context value. Made things simpler when creating / comparing the numbers. This was needed to allow sorting elements from different (but equal) stacking contexts correctly. Before they would be sorted as equal (stacking contexts were the same value) and then relied on the document order and positional sorting (based on float or inline), even when they belonged to different stacking context and shouldn't be sorted by position. Now the elements will only be positionally sorted when they belong to the same stacking context.
It should be noted that this fix doesn't actually result in resolving the incomplete in #4041. There is another element (
.tmpl-header_searchBtnContainer
) that is on top of the others (with a transparent background) and so the incomplete is correct that there is another element overlapping the links. I didn't realize this until after I made the stack correct.Closes: #4041