-
Notifications
You must be signed in to change notification settings - Fork 24
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: input-time: ignore some hierarchical mixin functionality #5079
base: main
Are you sure you want to change the base?
Changes from all commits
7fea22b
30a5b6b
14e54c1
a4ce2ad
287091d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,16 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
/** | ||
* @ignore | ||
*/ | ||
childView: { type: Boolean, reflect: true, attribute: 'child-view' }, | ||
hierarchicalView: { type: Boolean }, | ||
/** | ||
* @ignore | ||
*/ | ||
hierarchicalView: { type: Boolean }, | ||
rootView: { type: Boolean, attribute: 'root-view' }, | ||
/** | ||
* @ignore | ||
*/ | ||
shown: { type: Boolean, reflect: true } | ||
shown: { type: Boolean, reflect: true }, | ||
_childView: { type: Boolean, reflect: true, attribute: 'child-view' }, | ||
}; | ||
} | ||
|
||
|
@@ -97,10 +98,11 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
constructor() { | ||
super(); | ||
|
||
/** @ignore */ | ||
this.childView = false; | ||
/** @ignore */ | ||
this.hierarchicalView = true; | ||
/** @ignore */ | ||
this.rootView = false; | ||
this._childView = false; | ||
this.__focusPrevious = false; | ||
this.__intersectionObserver = null; | ||
this.__isAutoSized = false; | ||
|
@@ -135,7 +137,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
} | ||
this.__startResizeObserver(); | ||
|
||
if (!this.childView) { | ||
if (!this._childView) { | ||
this.addEventListener('focus', this.__focusCapture, true); | ||
this.addEventListener('focusout', this.__focusOutCapture, true); | ||
this.__onWindowResize = this.__onWindowResize.bind(this); | ||
|
@@ -167,7 +169,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
|
||
const stopPropagation = e => { | ||
// only stop for child views, so that Esc from root view can close dropdown | ||
if (!this.childView) return; | ||
if (!this._childView) return; | ||
e.stopPropagation(); | ||
}; | ||
|
||
|
@@ -198,15 +200,18 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
} | ||
|
||
getRootView() { | ||
if (!this.childView) { | ||
if (this.rootView || !this._childView) { | ||
return this; | ||
} | ||
const rootView = findComposedAncestor( | ||
this.parentNode, | ||
(node) => { | ||
return node.hierarchicalView && !node.childView; | ||
return node.rootView || (node.hierarchicalView && !node._childView); | ||
} | ||
); | ||
if (rootView) { | ||
rootView.rootView = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious about thoughts on this - if the rootView were to change then I believe this could cause problems. For example:
but then we add another view above:
Though I believe this would also be a problem with the current childView logic, as if something that's a child-view becomes the root-view, it would still have the child-view attribute on it, so perhaps this is a case we don't currently support. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is the method Kinda looks like I'm wondering if we should similarly initialize
So if a view is added above, it depends on how that's done. If new DOM is being constructed to insert the element above in the DOM, then With Edit: if we do this, I propose we rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool I think that makes sense to me. I'll update that. Thanks! |
||
} | ||
return rootView; | ||
} | ||
|
||
|
@@ -228,7 +233,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
} | ||
|
||
isActive() { | ||
if ((this.childView && !this.shown) || !this.shadowRoot) { | ||
if ((this._childView && !this.shown) || !this.shadowRoot) { | ||
return false; | ||
} else { | ||
const content = this.shadowRoot.querySelector('.d2l-hierarchical-view-content'); | ||
|
@@ -289,7 +294,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
} | ||
|
||
__autoSize(view) { | ||
if (this.__isAutoSized || this.childView) return; | ||
if (this.__isAutoSized || this._childView) return; | ||
requestAnimationFrame(() => { | ||
|
||
if (view.offsetParent === null) return; | ||
|
@@ -421,13 +426,17 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
} | ||
|
||
__isChildView() { | ||
if (this.rootView) { | ||
this._childView = false; | ||
return; | ||
} | ||
const parentView = findComposedAncestor( | ||
this.parentNode, | ||
(node) => { return node.hierarchicalView; } | ||
); | ||
|
||
if (parentView) { | ||
this.childView = true; | ||
this._childView = true; | ||
} | ||
} | ||
|
||
|
@@ -484,7 +493,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
} | ||
|
||
__onKeyDown(e) { | ||
if (this.childView && e.keyCode === escapeKeyCode) { | ||
if (this._childView && e.keyCode === escapeKeyCode) { | ||
e.stopPropagation(); | ||
this.hide(); | ||
return; | ||
|
@@ -498,7 +507,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass { | |
const rootTarget = e.composedPath()[0]; | ||
if (rootTarget === this || !rootTarget.hierarchicalView) return; | ||
|
||
if (this.childView && !this.shown) { | ||
if (this._childView && !this.shown) { | ||
/* deep link scenario */ | ||
this.show(e.detail.data, e.detail.sourceView); | ||
} | ||
|
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 in other cases we similarly apply the underscore to the reflected property (
_child-view
). It's not a big deal, but when we see the attribute in the dev console it becomes extra clear that's it has been reflected internally.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 is used in the LMS code here so we'd want to update that somewhat semi-simultaneously if we want to make that change.
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.
Gotcha. Ok, maybe not worth it depending on your thoughts on my other comment (i.e. consumers would be able to use the public
rootView
instead, setting us up to eventually removechildView
).