mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-21 08:45:32 +03:00
Attempt to fix column focus bug
This commit is contained in:
parent
c9295ba48e
commit
6a4e14267a
2 changed files with 31 additions and 2 deletions
|
@ -107,6 +107,18 @@ function Columns() {
|
|||
states.showShortcutsSettings = true;
|
||||
}
|
||||
}}
|
||||
onFocus={() => {
|
||||
// Get current focused column
|
||||
const currentFocusedColumn =
|
||||
document.activeElement.closest('#columns > *');
|
||||
if (currentFocusedColumn) {
|
||||
// Remove focus classes from all columns
|
||||
// Add focus class to current focused column
|
||||
document.querySelectorAll('#columns > *').forEach((column) => {
|
||||
column.classList.toggle('focus', column === currentFocusedColumn);
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
{components}
|
||||
</div>
|
||||
|
|
|
@ -2,8 +2,25 @@ const focusDeck = () => {
|
|||
let timer = setTimeout(() => {
|
||||
const columns = document.getElementById('columns');
|
||||
if (columns) {
|
||||
// Focus first column
|
||||
columns.querySelector('.deck-container')?.focus?.();
|
||||
// Focus focused column
|
||||
const focusedColumn = columns.querySelector('.deck-container.focus');
|
||||
if (focusedColumn) {
|
||||
focusedColumn.focus();
|
||||
} else {
|
||||
// Focus first column within viewport
|
||||
const firstVisibleColumn = columns
|
||||
.querySelectorAll('.deck-container')
|
||||
.find((column) => {
|
||||
const columnRect = column.getBoundingClientRect();
|
||||
return columnRect.left >= 0;
|
||||
});
|
||||
if (firstVisibleColumn) {
|
||||
firstVisibleColumn.focus();
|
||||
} else {
|
||||
// Focus first column
|
||||
columns.querySelector('.deck-container')?.focus?.();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const modals = document.querySelectorAll('#modal-container > *');
|
||||
if (modals?.length) {
|
||||
|
|
Loading…
Reference in a new issue