-
Notifications
You must be signed in to change notification settings - Fork 80
fix(tree, tree-item): works when tree is the topmost element in a shadow root where it has no parent #5472
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
Merged
jcfranco
merged 12 commits into
master
from
elijbet/5333-update-tree-to-work-without-parent
Oct 18, 2022
Merged
fix(tree, tree-item): works when tree is the topmost element in a shadow root where it has no parent #5472
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c5e386d
fix(tree, tree-item): works when tree is in the root node, in cases w…
Elijbet 2fd4874
add more checks
Elijbet 54d679f
Merge branch 'master' into elijbet/5333-update-tree-to-work-without-p…
Elijbet 0b0a827
test for renderign when tree is in the root node (there is no parent)
Elijbet bcb1744
Merge branch 'master' into elijbet/5333-update-tree-to-work-without-p…
Elijbet 3396584
cleanup
Elijbet ba98ab8
modify to assert that no error is thrown instead of using renders sin…
Elijbet 373c23b
Merge branch 'master' into elijbet/5333-update-tree-to-work-without-p…
Elijbet f9105cc
remove call as this should be captured in defineTestElement
Elijbet 742537f
Merge branch 'master' into elijbet/5333-update-tree-to-work-without-p…
Elijbet b1aa7ec
Merge branch 'master' into elijbet/5333-update-tree-to-work-without-p…
Elijbet 4ede605
tweak test
jcfranco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ export class Tree { | |
//-------------------------------------------------------------------------- | ||
|
||
componentWillRender(): void { | ||
const parent: HTMLCalciteTreeElement = this.el.parentElement.closest("calcite-tree"); | ||
const parent: HTMLCalciteTreeElement = this.el.parentElement?.closest("calcite-tree"); | ||
this.lines = parent ? parent.lines : this.lines; | ||
this.scale = parent ? parent.scale : this.scale; | ||
this.selectionMode = parent ? parent.selectionMode : this.selectionMode; | ||
|
@@ -283,7 +283,7 @@ export class Tree { | |
} | ||
|
||
// When focus is on a child node that is also either an end node or a closed node, moves focus to its parent node. | ||
const parentItem = target.parentElement.closest("calcite-tree-item"); | ||
const parentItem = target.parentElement?.closest("calcite-tree-item"); | ||
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. Per our convo, this and the updates below ( |
||
|
||
if (parentItem && (!target.hasChildren || target.expanded === false)) { | ||
parentItem.focus(); | ||
|
@@ -320,10 +320,10 @@ export class Tree { | |
} | ||
|
||
const ancestors: HTMLCalciteTreeItemElement[] = []; | ||
let parent = item.parentElement.closest<HTMLCalciteTreeItemElement>("calcite-tree-item"); | ||
let parent = item.parentElement?.closest<HTMLCalciteTreeItemElement>("calcite-tree-item"); | ||
while (parent) { | ||
ancestors.push(parent); | ||
parent = parent.parentElement.closest<HTMLCalciteTreeItemElement>("calcite-tree-item"); | ||
parent = parent.parentElement?.closest<HTMLCalciteTreeItemElement>("calcite-tree-item"); | ||
} | ||
|
||
const childItems = Array.from( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.