fix: Vim keymap insert mode exiting after single keystroke #10714
Merged
yuki-takei merged 2 commits intomasterfrom Jan 15, 2026
Merged
fix: Vim keymap insert mode exiting after single keystroke #10714yuki-takei merged 2 commits intomasterfrom
yuki-takei merged 2 commits intomasterfrom
Conversation
miya
commented
Jan 14, 2026
| const onSaveRef = useRef(onSave); | ||
| useEffect(() => { | ||
| onSaveRef.current = onSave; | ||
| }, [onSave]); |
Member
Author
There was a problem hiding this comment.
useRef を用意し、引数から渡ってきた onSave を常に最新のも参照させるための useEffect
| }; | ||
| settingKeyMap(keymapMode); | ||
| }, [keymapMode, onSave]); | ||
| }, [keymapMode]); |
Member
Author
There was a problem hiding this comment.
この useEffect の依存配列から引数から渡ってきた onSave を抜いて keymapExtension state を複数回更新させないように修正
| setKeymapExtension(await getKeymap(name, stableOnSave)); | ||
| }; | ||
| settingKeyMap(keymapMode); | ||
| }, [keymapMode, onSave]); |
Member
Author
There was a problem hiding this comment.
バグの原因
useKeymapExtension フック内で onSave が useEffect の依存配列に入っていたことで onSave が変更される度に keymapExtension state が更新されていた。keymapExtension が更新されることで下記の useEffect により codeMirrorEditor?.appendExtensions が呼ばれていたことが原因
growi/packages/editor/src/client/stores/use-editor-settings.ts
Lines 111 to 121 in 0d126d8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
https://redmine.weseek.co.jp/issues/176960