editor: disable the "Add champ" button until the champ is saved
Otherwise some champs are created before the previous one has been saved, and React complains that several champs have the same `champ-undefined` key. (Plus it made the tests flaky and unreliable.)
This commit is contained in:
parent
7ed649dfca
commit
52051914aa
1 changed files with 3 additions and 0 deletions
|
@ -12,6 +12,8 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
|
|||
typeDeChamps
|
||||
});
|
||||
|
||||
const hasUnsavedChamps = state.typeDeChamps.some(tdc => tdc.id == undefined);
|
||||
|
||||
return (
|
||||
<div className="champs-editor">
|
||||
<SortableContainer
|
||||
|
@ -43,6 +45,7 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
|
|||
<div className="buttons">
|
||||
<button
|
||||
className="button"
|
||||
disabled={hasUnsavedChamps}
|
||||
onClick={() =>
|
||||
dispatch({
|
||||
type: 'addNewTypeDeChamp',
|
||||
|
|
Loading…
Reference in a new issue