mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-22 20:41:39 -08:00
feat: Auto-select the first file if none is selected
This commit is contained in:
parent
4853ec6061
commit
e5dc4e3ffc
1 changed files with 9 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ import { styled } from '@mui/material/styles';
|
|||
import Tab from '@mui/material/Tab';
|
||||
import Tabs from '@mui/material/Tabs';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { getFileStatusStyles, type GitFileStatus } from './fileStatusStyles';
|
||||
|
|
@ -85,6 +85,13 @@ export function CommitDetailsPanel(
|
|||
// Use files from commit entry (already loaded in useGitLogData)
|
||||
const fileChanges = commit?.files ?? [];
|
||||
|
||||
// Auto-select the first file if none is selected
|
||||
useEffect(() => {
|
||||
if (fileChanges.length > 0 && !selectedFile && onFileSelect) {
|
||||
onFileSelect(fileChanges[0].path);
|
||||
}
|
||||
}, [commit, fileChanges, selectedFile, onFileSelect]);
|
||||
|
||||
const handleRevert = async () => {
|
||||
if (!commit || isReverting) return;
|
||||
|
||||
|
|
@ -141,7 +148,7 @@ export function CommitDetailsPanel(
|
|||
|
||||
const handleCopyHash = () => {
|
||||
if (!commit) return;
|
||||
navigator.clipboard.writeText(commit.hash);
|
||||
void navigator.clipboard.writeText(commit.hash);
|
||||
};
|
||||
|
||||
const handleOpenInGitHub = async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue