fix issue undo history number input
This commit is contained in:
@@ -73,9 +73,15 @@ export function NumberInput({
|
||||
document.removeEventListener('mousemove', handleMouseMove)
|
||||
document.removeEventListener('mouseup', handleMouseUp)
|
||||
|
||||
// Resume history tracking and commit final value
|
||||
// Reset to initial value while still paused (no history entry)
|
||||
// Then resume and apply final value (creates single history entry)
|
||||
if (finalValue !== startValueRef.current) {
|
||||
onChange(startValueRef.current)
|
||||
useScene.temporal.getState().resume()
|
||||
onChange(finalValue)
|
||||
} else {
|
||||
useScene.temporal.getState().resume()
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('mousemove', handleMouseMove)
|
||||
|
||||
@@ -215,13 +215,11 @@ useScene.temporal.subscribe((state) => {
|
||||
const currentPastLength = state.pastStates.length
|
||||
const currentFutureLength = state.futureStates.length
|
||||
|
||||
|
||||
// Undo: futureStates increases (state moved from past to future)
|
||||
// Redo: pastStates increases while futureStates decreases (state moved from future to past)
|
||||
const didUndo = currentFutureLength > prevFutureLength
|
||||
const didRedo = currentPastLength > prevPastLength && currentFutureLength < prevFutureLength
|
||||
|
||||
|
||||
if (didUndo || didRedo) {
|
||||
// Use RAF to ensure all middleware and store updates are complete
|
||||
requestAnimationFrame(() => {
|
||||
|
||||
Reference in New Issue
Block a user