mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
Fixes #747
This commit is contained in:
parent
3968287084
commit
ed395e42b7
1 changed files with 13 additions and 3 deletions
|
@ -1,6 +1,4 @@
|
|||
<script>
|
||||
// TODO: add function to programmatically expand/collapse parent nodes
|
||||
|
||||
/**
|
||||
* @typedef {string | number} TreeNodeId
|
||||
* @typedef {{ id: TreeNodeId; text: string; icon?: typeof import("carbon-icons-svelte").CarbonIcon; disabled?: boolean; expanded?: boolean; }} TreeNode
|
||||
|
@ -40,7 +38,7 @@
|
|||
/** Set to `true` to visually hide the label text */
|
||||
export let hideLabel = false;
|
||||
|
||||
import { createEventDispatcher, setContext } from "svelte";
|
||||
import { createEventDispatcher, setContext, onMount } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
import TreeViewNodeList from "./TreeViewNodeList.svelte";
|
||||
|
||||
|
@ -82,6 +80,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if ($activeNodeId === "") {
|
||||
const firstFocusableNode = ref.querySelector(
|
||||
"li.bx--tree-node:not(.bx--tree-node--disabled)"
|
||||
);
|
||||
|
||||
if (firstFocusableNode != null) {
|
||||
firstFocusableNode.tabIndex = "0";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$: activeNodeId.set(activeId);
|
||||
$: selectedNodeIds.set(selectedIds);
|
||||
$: if (ref) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue