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
|
typeDeChamps
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hasUnsavedChamps = state.typeDeChamps.some(tdc => tdc.id == undefined);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="champs-editor">
|
<div className="champs-editor">
|
||||||
<SortableContainer
|
<SortableContainer
|
||||||
|
@ -43,6 +45,7 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
|
||||||
<div className="buttons">
|
<div className="buttons">
|
||||||
<button
|
<button
|
||||||
className="button"
|
className="button"
|
||||||
|
disabled={hasUnsavedChamps}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'addNewTypeDeChamp',
|
type: 'addNewTypeDeChamp',
|
||||||
|
|
Loading…
Reference in a new issue