Restore React purity checks and streamline inline drafts
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
This commit is contained in:
parent
2bff58f08c
commit
b9cc77a4d1
8 changed files with 111 additions and 10 deletions
|
|
@ -22,6 +22,13 @@ export function useInlineEdit({
|
|||
const inputRef = useRef(null);
|
||||
const skipCommitRef = useRef(false);
|
||||
const [draft, setDraft] = useState(value);
|
||||
const [previousValue, setPreviousValue] = useState(value);
|
||||
|
||||
// Réinitialise avant le commit DOM, uniquement si la valeur source a changé.
|
||||
if (!Object.is(previousValue, value)) {
|
||||
setPreviousValue(value);
|
||||
setDraft(value);
|
||||
}
|
||||
|
||||
function syncContentEditable(nextValue, force = false) {
|
||||
if (inputRef.current?.isContentEditable && (force || document.activeElement !== inputRef.current)) {
|
||||
|
|
@ -30,7 +37,6 @@ export function useInlineEdit({
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
setDraft(value);
|
||||
syncContentEditable(value);
|
||||
}, [value]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue