fix(components): [tree] add optional chains to ensure el$ exists (#23137)

* fix(components): [tree] When a hot update occurs, the element does not exist.

* refactor: simplify

---------

Co-authored-by: Dsaquel <291874700n@gmail.com>
This commit is contained in:
xiejiahe
2025-12-18 21:35:24 +08:00
committed by GitHub
parent c30a92713d
commit 8c4aaec835

View File

@@ -19,10 +19,7 @@ export function useKeydown({ el$ }: UseKeydownOption, store: Ref<TreeStore>) {
})
onUpdated(() => {
const checkboxItems = Array.from(
el$.value!.querySelectorAll('input[type=checkbox]')
)
checkboxItems.forEach((checkbox) => {
el$.value?.querySelectorAll('input[type=checkbox]').forEach((checkbox) => {
checkbox.setAttribute('tabindex', '-1')
})
})