mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-21 10:53:27 +03:00
23 lines
668 B
React
23 lines
668 B
React
|
const focusDeck = () => {
|
||
|
let timer = setTimeout(() => {
|
||
|
const columns = document.getElementById('columns');
|
||
|
if (columns) {
|
||
|
// Focus first column
|
||
|
// columns.querySelector('.deck-container')?.focus?.();
|
||
|
} else {
|
||
|
const backDrop = document.querySelector('.deck-backdrop');
|
||
|
if (backDrop) return;
|
||
|
// Focus last deck
|
||
|
const pages = document.querySelectorAll('.deck-container');
|
||
|
const page = pages[pages.length - 1]; // last one
|
||
|
if (page && page.tabIndex === -1) {
|
||
|
console.log('FOCUS', page);
|
||
|
page.focus();
|
||
|
}
|
||
|
}
|
||
|
}, 100);
|
||
|
return () => clearTimeout(timer);
|
||
|
};
|
||
|
|
||
|
export default focusDeck;
|