-
Notifications
You must be signed in to change notification settings - Fork 272
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
feat: ui5-tree (new component) #1580
Conversation
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.
The code look good to me, it would be good to have few tests
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.
There is sth minor that can be implemented later, but just to mention it, the user cant drill up and down the nodes with ARROW-RIGHT|LEFT keys.
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.
also we will need a sample.html for the playground
* @alias sap.ui.webcomponents.main.Tree | ||
* @extends UI5Element | ||
* @tagname ui5-tree | ||
* @appenddocs TreeItem |
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.
add since
* @constructor | ||
* @author SAP SE | ||
* @alias sap.ui.webcomponents.main.TreeItem | ||
* @extends UI5Element |
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.
add since
@@ -0,0 +1,188 @@ | |||
<header> |
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.
To display since there is special marker:
<header class="component-heading">
<h2 class="control-header">Tree</h2>
<div class="component-heading-since">
<span><!--since_tag_marker--></span>
</div>
</header>
<script> | ||
var dynamicTree = document.getElementById("treeDynamic"); | ||
dynamicTree.addEventListener("itemToggle", function(event) { | ||
const item = event.detail.item; // get the node that is toggled |
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.
There are some "const" in the Tree.html and Tree.sample.html, maybe we should replace them with vars.
packages/main/src/Tree.js
Outdated
/** | ||
* Defines the <code>ui5-tree</code> header. | ||
* <br><br> | ||
* <b>Note:</b> When <code>header</code> is set, the |
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.
header
slot is set..
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.
Done
packages/main/src/Tree.js
Outdated
} | ||
|
||
onEnterDOM() { | ||
this._observer = new MutationObserver(this.onTreeStructureChange.bind(this)); |
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.
Perhaps we can check if the _observer is available and not create multiple observers if the tree is added and removed from the DOM
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.
Done, moved to constructor
packages/main/src/Tree.js
Outdated
} | ||
|
||
get list() { | ||
return this.shadowRoot.querySelector(`ui5-list`); |
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.getDomRef.querySelector()
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.
Done, when I removed the busy indicator, this.getDomRef() is the list (top-level element) but I kept the getter for semantics
} | ||
} | ||
|
||
const walkTree = (el, level, callback) => { |
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.
Have you considered walkTree & buildTree to be static methods in the Tree class?
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.
Yeah, I thought about it, but I prefer them hidden for the moment
ui5-tree
:ui5-list
, but does not extend it, composes it instead and proxies properties/slots/events to/from it.ui5-tree-item
as an abstract (no-renderer) item recursivelyui5-list
internally usesui5-li-tree
- a specific tree item, not intended for the end user, only for internal usage in the list of the treerole=tree
for the tree itself;role=treeitem
,ariaExpanded
bound to theexpanded
property, andariaLevel
bound to the level property for tree list itemscalc
)itemToggle
can be prevented by the user in order to fetch tree items dynamically, and then the toggling can be done manually withtoggle()
on the tree node.managedSlots: true
so they never know if they change and they never invalidate the tree directly._id
s so thatlithtml
can insert/delete, rather than overwrite list items, when tree items are modified.Additionally, fixed some findings in related files:
List.js
small doc fixesListItem.css
invalid host selector:host()
instead of just:host
sizes-parameters.css
many duplicated vars deletedcloses: #1550