mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
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:
co-authored by
karilint
parent
35c4091fc5
commit
8e070f3cc1
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user