Improve UX consistency - disable button in staging mode when not dirty

Co-authored-by: karilint <19990676+karilint@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-09 11:15:35 +00:00
co-authored by karilint
parent 35c4091fc5
commit 8e070f3cc1
2 changed files with 4 additions and 9 deletions
@@ -211,7 +211,7 @@ export const WriteButton = <T,>({
>
<span>
<Button
disabled={Object.keys(fieldsWithErrors).length > 0 || (!mode.staging && !isDirty)}
disabled={Object.keys(fieldsWithErrors).length > 0 || !isDirty}
id="write-button"
sx={{ width: '20em' }}
onClick={() => {
@@ -200,7 +200,7 @@ describe('WriteButton taxonomy handling', () => {
expect((button as HTMLButtonElement).disabled).toBe(false)
})
it('blocks finalize handler and shows feedback when dirty flag is false', async () => {
it('disables the button in staging mode when no edits have been made', () => {
const onWrite = jest.fn(() => Promise.resolve())
renderButton(baseSpecies as EditDataType<Species>, onWrite, {
@@ -208,12 +208,7 @@ describe('WriteButton taxonomy handling', () => {
mode: modeStagingEdit,
})
fireEvent.click(screen.getByRole('button', { name: /complete and save/i }))
await waitFor(() => {
expect(onWrite).not.toHaveBeenCalled()
})
expect(mockNotify).toHaveBeenCalledWith('Please make changes before finalizing the entry.', 'info')
const button = screen.getByRole('button', { name: /complete and save/i })
expect((button as HTMLButtonElement).disabled).toBe(true)
})
})