mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-18 08:32:33 +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;
|
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}
|
{components}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,8 +2,25 @@ const focusDeck = () => {
|
||||||
let timer = setTimeout(() => {
|
let timer = setTimeout(() => {
|
||||||
const columns = document.getElementById('columns');
|
const columns = document.getElementById('columns');
|
||||||
if (columns) {
|
if (columns) {
|
||||||
|
// 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
|
// Focus first column
|
||||||
columns.querySelector('.deck-container')?.focus?.();
|
columns.querySelector('.deck-container')?.focus?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const modals = document.querySelectorAll('#modal-container > *');
|
const modals = document.querySelectorAll('#modal-container > *');
|
||||||
if (modals?.length) {
|
if (modals?.length) {
|
||||||
|
|
Loading…
Reference in a new issue