-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: Prevent Arc browser undo on Cmd+Z in Drawnix #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Prevent Arc browser undo on Cmd+Z in Drawnix #254
Conversation
|
@coderwei99 Great job, very fine improvement! However, I make a mistake for hotkey plugin, I should overridden keydown to implement the hotkey plugin, because we can not stop the default undo action in the globalKeyDown function, the undo will exec twice 😂, you could change it in this pr or ignore it(I will correct it later). Add |
|
@pubuzhixing8 My mistake — I didn’t take the native Plait undo behavior into account. |
|
Look good to me @coderwei99 , ready to merge. I would replace the overridden method |
|
After my investigation, I found that the undo action really was being executed twice. I plan to fix this by modifying the code as follows: const { globalKeyDown, keyDown } = board;
board.globalKeyDown = (event: KeyboardEvent) => {
// ... other code
}
board.keyDown = (event: KeyboardEvent) => {
if (isHotkey(['mod+z'], { byKey: true })(event)) {
board.undo();
event.preventDefault();
return;
}
if (isHotkey(['mod+shift+z'], { byKey: true })(event)) {
board.redo();
event.preventDefault();
return;
}
keyDown(event);
};And I will remove the undo logic from
|
Cool @coderwei99 , new code segment is good to resolve the issue perfectly. |
|
Look good to me! |
Description
In the Arc browser on macOS, pressing
Cmd+Zin Drawnix triggers both the Plait framework's undo action (board.undo()) and the browser's default undo action, which reopens the last closed tab. This creates a confusing user experience as the browser's action interferes with the expected whiteboard undo behavior.This PR adds explicit handling of the
Cmd+Zkeybinding in thebuildDrawnixHotkeyPluginto:board.undo()to perform the Plait undo action.event.preventDefault()to prevent event propagation, blocking the Arc browser's default undo behavior.No additional custom logic was added beyond the Plait undo action, ensuring minimal changes while resolving the issue.
Testing
Cmd+Zand verify:Cmd+Zbehavior.Impact
Cmd+Z.Cmd+Zkeybinding.