mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 02:26:14 +03:00
Setting focus using element ids
This commit is contained in:
parent
060ccbb40a
commit
cf448848d0
@ -44,7 +44,9 @@
|
|||||||
}}
|
}}
|
||||||
on:keydown={(e) => {
|
on:keydown={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($selectedFiles.length > 1) return;
|
if ($selectedFiles.length !== 1) return;
|
||||||
|
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
|
||||||
|
|
||||||
const selectedFileIndex = sortedFiles.findIndex((sf) => sf.id === $selectedFiles[0].id);
|
const selectedFileIndex = sortedFiles.findIndex((sf) => sf.id === $selectedFiles[0].id);
|
||||||
|
|
||||||
if (e.key === 'ArrowUp') {
|
if (e.key === 'ArrowUp') {
|
||||||
@ -54,6 +56,9 @@
|
|||||||
if (selectedFileIndex + 1 > sortedFiles.length - 1) return;
|
if (selectedFileIndex + 1 > sortedFiles.length - 1) return;
|
||||||
$selectedFiles = [sortedFiles[selectedFileIndex + 1]];
|
$selectedFiles = [sortedFiles[selectedFileIndex + 1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fileElement = document.getElementById('file-' + $selectedFiles[0].id);
|
||||||
|
fileElement?.focus();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
Reference in New Issue
Block a user