Skip to content

Conversation

@TCOTC
Copy link
Contributor

@TCOTC TCOTC commented Dec 7, 2025

长按键盘无法在 textarea 里连续输入文本或者删除文本,只能一个字母一个字母按,所以把 event.repeat 去掉。

之前连续按回车会重复创建笔记本的问题 #15150 仍然存在,把间隔时间改大了一点到 200ms。

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an issue where users could not continuously input or delete characters in text areas by holding down keys. The fix removes the event.repeat check that was blocking key repeat events, and increases the debounce interval for Enter key handling to mitigate a related bug where holding Enter would create multiple notebooks.

Key changes:

  • Removed event.repeat condition from the keydown event handler to allow continuous character input/deletion
  • Increased the debounce interval from 124ms to 200ms for Enter key handling to prevent duplicate submissions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +115 to 117
if (event.isComposing) {
event.preventDefault();
return;
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the event.repeat check could have unintended consequences. While removing it allows continuous input/deletion by holding keys, it also removes protection against repeat events for special keys like Escape. The Escape key handler will now trigger repeatedly when held down, which could cause multiple rapid dialog destructions or race conditions. Consider handling event.repeat selectively - allow repeats for normal input but prevent them for action keys like Escape and Enter.

Copilot uses AI. Check for mistakes.
Comment on lines +126 to 128
if (timeStamp && event.timeStamp - timeStamp < 200) {
return;
}
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debounce interval change from 124ms to 200ms appears arbitrary and may not be sufficient to prevent double-submission issues. This value doesn't align with any standard debounce timing (e.g., 250ms, 300ms) and the choice of 200ms should be documented with a comment explaining why this specific duration was chosen. Additionally, consider whether this approach is robust enough - a timestamp-based debounce can still be bypassed by users who press Enter with deliberate timing.

Copilot uses AI. Check for mistakes.
@Vanessa219 Vanessa219 merged commit ddeb9b7 into siyuan-note:dev Dec 21, 2025
7 checks passed
Vanessa219 added a commit that referenced this pull request Dec 21, 2025
@Vanessa219
Copy link
Member

3.5.1

@TCOTC TCOTC deleted the fix/input branch December 21, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants