anytype-ts
anytype-ts copied to clipboard
Using Capslock to switch English mode under Chinese IME on MacOS resulting in wrong editor behavior
Have you read a contributing guide?
- [x] I have read CONTRIBUTING.md
- [x] I have searched the existing issues and didn't find any that were similar
- [x] I have considered creating a pull request with fixes instead of a bug report and want to proceed
Current Behavior
When capslock is activated, IME will turn into English input, pressing "Enter" isn't creating a new text block, but line break is inserted.
Expected Behavior
Pressing "Enter" key should creating a new text block instead of inserting a line break.
Steps To Reproduce
- Use Chinese IME or any other IME that can use Capslock to turn into English mode
- Press "Enter"
- Line break is inserted
Environment
- OS:macOS 15.6
- Version: 0.49.8
Anything else?
Root Cause Analysis
I've confirmed the problem is on pressed key detection logic on /src/ts/component/block/test.tsx > BlockText > onKeyDown (L1038).
// Enter
keyboard.shortcut('enter, shift+enter', e, (pressed: string) => {
if (isInsideTable && (pressed == 'enter')) {
this.onArrowVertical(e, Key.down, { from: length, to: length }, length, props);
} else {
this.onEnterBlock(e, range, pressed);
};
});
As the pressed button logic in /src/ts/lib/keyboard.ts > keyboard.shortcut shows, whenever Capslock is activated, the array of pressed buttons is appended with capslock, therefore the shortcut shown here isn't matched and causing the problem.
Suggesting Fix
Adding capslock+enter, capslock+shift+enter into keyboard.shortcut's matching string can fix this issue. However, it seems that this problem is just part of a broader set of related issues, so we should work toward a more universal fix instead of a one-off workaround.