mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-10-06 00:47:09 +03:00
Fix: wrong focus on the last selected item
This commit is contained in:
parent
e707bdd812
commit
328c3e6f16
@ -74,6 +74,8 @@
|
||||
class:draggable={isDraggable}
|
||||
id={`file-${file.id}`}
|
||||
data-locked={file.locked}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
on:click
|
||||
on:keydown
|
||||
on:dragstart={async () => {
|
||||
@ -106,8 +108,6 @@
|
||||
draggableElt.classList.remove('locked-file-animation');
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
on:contextmenu|preventDefault={async (e) => {
|
||||
if (fileIdSelection.has(file.id, $commit?.id)) {
|
||||
popupMenu.openByMouse(e, { files: await $selectedFiles });
|
||||
|
@ -11,8 +11,9 @@ export function selectFilesInList(
|
||||
allowMultiple: boolean,
|
||||
commit: AnyCommit | undefined
|
||||
) {
|
||||
let selectedFileIds = get(fileIdSelection);
|
||||
e.stopPropagation();
|
||||
|
||||
let selectedFileIds = get(fileIdSelection);
|
||||
const isAlreadySelected = selectedFileIds && fileIdSelection.has(file.id, commit?.id);
|
||||
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
|
@ -46,8 +46,8 @@ export function maybeMoveSelection(
|
||||
) {
|
||||
if (selectedFileIds.length === 0) return;
|
||||
|
||||
const firstFileId = unstringifyFileKey(selectedFileIds[0]);
|
||||
const lastFileId = unstringifyFileKey(selectedFileIds[selectedFileIds.length - 1]);
|
||||
const firstFileId = unstringifyFileKey(selectedFileIds[selectedFileIds.length - 1]);
|
||||
const lastFileId = unstringifyFileKey(selectedFileIds[0]);
|
||||
let selectionDirection = getSelectionDirection(
|
||||
files.findIndex((f) => f.id === lastFileId),
|
||||
files.findIndex((f) => f.id === firstFileId)
|
||||
@ -87,6 +87,7 @@ export function maybeMoveSelection(
|
||||
} else if (selectionDirection === 'down') {
|
||||
fileIdSelection.remove(lastFileId);
|
||||
}
|
||||
|
||||
getAndAddFile(getPreviousFile, lastFileId);
|
||||
} else {
|
||||
// Handle reset of selection
|
||||
|
@ -56,7 +56,7 @@ export class FileIdSelection {
|
||||
}
|
||||
|
||||
add(fileId: string, commitId?: string) {
|
||||
this.value.push(stringifyFileKey(fileId, commitId));
|
||||
this.value.unshift(stringifyFileKey(fileId, commitId));
|
||||
this.emit();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user