Skip to content

Commit

Permalink
Merge pull request #57 from Saeid-Za/main
Browse files Browse the repository at this point in the history
fix: resolve #56 via checking for array type
  • Loading branch information
xiaoluoboding authored Mar 6, 2024
2 parents 1c6020f + c03d9dc commit 23cd00e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/Toaster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const actualTheme = ref(
)
const cnFunction = computed(() => props.cn || _cn)
const listRef = ref<HTMLOListElement | null>(null)
const listRef = ref<HTMLOListElement[] | HTMLOListElement | null>(null)
const lastFocusedElementRef = ref<HTMLElement | null>(null)
const isFocusWithinRef = ref(false)
Expand Down Expand Up @@ -358,16 +358,16 @@ watchEffect((onInvalidate) => {
(key) => (event as any)[key] || event.code === key
)
const listRefItem = Array.isArray(listRef.value) ? listRef.value[0] : listRef.value
if (isHotkeyPressed) {
expanded.value = true
listRef.value?.focus()
listRefItem?.focus()
}
if (
event.code === 'Escape' &&
(document.activeElement === listRef.value ||
listRef.value?.contains(document.activeElement))
) {
const isItemActive = document.activeElement === listRef.value || listRefItem?.contains(document.activeElement)
if (event.code === 'Escape' && isItemActive) {
expanded.value = false
}
}
Expand Down

0 comments on commit 23cd00e

Please sign in to comment.