fix: prevent unintended history entry#1533
Conversation
|
@DamianKocjan is attempting to deploy a commit to the Puck Team on Vercel. A member of the Team first needs to authorize it. |
Avoid creating history entries when the field content hasn't actually changed. This occurs when rapidly clicking a RichText field and deselecting block, which would previously record a history entry despite no visual changes to the document. The fix compares the current field value with the debounced content and skips the `onChange` callback if they match, preventing unnecessary history pollution.
chrisvxd
left a comment
There was a problem hiding this comment.
works great now, just 1 comment on unrelated code and a conflict to address
| const currentData = appStoreApi.getState().getCurrentData(); | ||
| const currentFieldValue = getDeep(currentData.props, name ?? ""); | ||
|
|
||
| // Avoid echoing back same content | ||
| if (currentFieldValue === debouncedState.html) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This looks like its leaked into this PR. If this is intentional, can you capture as a separate PR with relevant issue?
There was a problem hiding this comment.
It was intentional. When I was testing against unintentional history entries I found that issue, so I fixed it. Thought it'd be ideal to merge it here with rest of related changes.
Commit addressing this issue with explanation: fc58153
I'll create issue and PR later that day. Or we can add one more issue that this PR is addressing.
There was a problem hiding this comment.
I've been thinking about it too. So I'll probably undo this commit from this pr and see if issue still persist after fix in #1587
chrisvxd
left a comment
There was a problem hiding this comment.
Oops approved prematurely! Needs conflicts addressed :)
|
@chrisvxd You can merge. Tested once again to be sure |
Closes #1521