- Added functionality to close the overlay and return focus to the launcher when the Escape key is pressed inside an iframe. - Implemented message handling to close the app launcher from the parent window. - Updated navigation logic in useControllerNav to improve focus management when navigating between sidebar and main content. - Enhanced Dashboard and Settings views with data attributes for better controller navigation support.
38 lines
865 B
TypeScript
38 lines
865 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
|
|
export const useAppLauncherStore = defineStore('appLauncher', () => {
|
|
const isOpen = ref(false)
|
|
const url = ref('')
|
|
const title = ref('')
|
|
let previousActiveElement: HTMLElement | null = null
|
|
|
|
function open(payload: { url: string; title: string }) {
|
|
previousActiveElement = (document.activeElement as HTMLElement) || null
|
|
url.value = payload.url
|
|
title.value = payload.title
|
|
isOpen.value = true
|
|
}
|
|
|
|
function close() {
|
|
const toRestore = previousActiveElement
|
|
previousActiveElement = null
|
|
isOpen.value = false
|
|
url.value = ''
|
|
title.value = ''
|
|
if (toRestore && typeof toRestore.focus === 'function') {
|
|
requestAnimationFrame(() => {
|
|
toRestore.focus()
|
|
})
|
|
}
|
|
}
|
|
|
|
return {
|
|
isOpen,
|
|
url,
|
|
title,
|
|
open,
|
|
close,
|
|
}
|
|
})
|