Skip to content

feat(edit-any-page): autofocus input and confirm on Enter - #30

Merged
dragon-fish merged 2 commits into
masterfrom
claude/issue-27-20261007-1420
Oct 7, 2026
Merged

dragon-fish merged 2 commits into
masterfrom
claude/issue-27-20261007-1420

Conversation

@dragon-fish

@dragon-fish dragon-fish commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

close #27

Sourcery 摘要

通过自动选择输入内容和键盘确认功能,改进任意页面编辑对话框。

新功能:

  • 在页面名称输入框中按 Enter 键即可确认页面编辑。
  • 模态框打开时,自动聚焦并选择页面名称输入框中的内容。

增强功能:

  • 集中处理页面名称提交和验证逻辑,同时支持模态框确认和表单提交。
Original summary in English

Sourcery 总结

改进编辑任意页面的对话框,提供更快捷的键盘确认方式和更便捷的初始输入状态。

新功能:

  • 允许用户在页面名称字段中按 Enter 键确认页面编辑。
  • 打开编辑对话框时,自动聚焦并选中页面名称。

增强功能:

  • 集中处理模态框和基于表单的确认流程中的页面名称验证与提交。
Original summary in English

Summary by Sourcery

Improve the edit-any-page dialog with faster keyboard confirmation and a more convenient initial input state.

New Features:

  • Allow users to confirm page edits by pressing Enter in the page name field.
  • Automatically focus and select the page name when the edit dialog opens.

Enhancements:

  • Centralize page name validation and submission for modal and form-based confirmation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: 机智的小鱼君 <44761872+dragon-fish@users.noreply.github.com>
@claude

claude Bot commented Oct 7, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@sourcery-ai

sourcery-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

审查者指南

该插件现在集中处理有效的页面提交,支持通过回车键确认编辑并在成功后关闭模态框,同时在模态框打开时自动聚焦并全选页面名称输入框。

任意页面编辑提交的时序图

sequenceDiagram
    actor User
    participant Plugin as EditAnyPagePlugin
    participant Modal
    participant QuickEdit

    User->>Plugin: Open edit-any-page
    Plugin->>Modal: confirm(pageNameForm)
    Plugin->>Plugin: requestAnimationFrame()
    Plugin->>Plugin: input.focus()
    Plugin->>Plugin: input.select()
    User->>Plugin: Press Enter
    Plugin->>Plugin: submit()
    alt page name is valid
        Plugin->>QuickEdit: quickEdit(title: pageName)
        Plugin->>Modal: close()
    else page name is empty
        Plugin-->>User: Keep modal open
    end
Loading

文件级变更

变更 详情 文件
集中处理页面名称验证和快速编辑提交,使模态框确认和回车键提交使用相同的行为。
  • 去除页面名称首尾空格,并拒绝空页面名称。
  • 使用输入的页面标题调用快速编辑。
  • 保留模态框确认回调行为。
packages/edit-any-page/src/index.ts
添加便于键盘操作的模态框交互和初始输入选择。
  • 通过回车处理表单提交,阻止浏览器默认行为,并在成功提交后关闭模态框。
  • 模态框挂载后聚焦并全选页面名称输入框中的内容。
packages/edit-any-page/src/index.ts

针对关联 issue 的评估

Issue 目标 已解决 说明
#27 打开编辑弹窗时自动聚焦输入框,并全选其中的现有页面名称。 ✅
#27 在编辑弹窗的输入框中按下回车时确认,并打开对应页面的编辑窗口。 ✅

可能关联的 issue


提示和命令

与 Sourcery 交互

  • 触发新的审查: 在 pull request 中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以在审查评论中回复 @sourcery-ai issue,以便从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title,以便随时重新生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary,以便随时重新生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此命令会很有用。
  • 忽略所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义使用体验

访问你的仪表板:

  • 启用或停用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

The plugin now centralizes valid page submission, supports confirming the edit via Enter with successful modal closure, and autofocuses/selects the page-name input when the modal opens.

Sequence diagram for edit-any-page submission

sequenceDiagram
    actor User
    participant Plugin as EditAnyPagePlugin
    participant Modal
    participant QuickEdit

    User->>Plugin: Open edit-any-page
    Plugin->>Modal: confirm(pageNameForm)
    Plugin->>Plugin: requestAnimationFrame()
    Plugin->>Plugin: input.focus()
    Plugin->>Plugin: input.select()
    User->>Plugin: Press Enter
    Plugin->>Plugin: submit()
    alt page name is valid
        Plugin->>QuickEdit: quickEdit(title: pageName)
        Plugin->>Modal: close()
    else page name is empty
        Plugin-->>User: Keep modal open
    end
Loading

File-Level Changes

Change Details Files
Centralize page-name validation and quick-edit submission so both modal confirmation and Enter-key submission use the same behavior.
  • Trim and reject empty page names.
  • Invoke quick edit with the entered page title.
  • Preserve modal confirmation callback behavior.
packages/edit-any-page/src/index.ts
Add keyboard-friendly modal interaction and initial input selection.
  • Handle form submission on Enter, prevent the browser default, and close the modal after successful submission.
  • Focus and select the entire page-name input after the modal is mounted.
packages/edit-any-page/src/index.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#27 打开编辑弹窗时自动聚焦输入框,并全选其中的现有页面名称。 ✅
#27 在编辑弹窗的输入框中按下回车时确认,并打开对应页面的编辑窗口。 ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嘿——我发现了 1 个问题

给 AI Agent 的提示
请处理这次代码审查中的评论:

## 单独评论

### 评论 1
<location path="packages/edit-any-page/src/index.ts" line_range="46-49" />
<code_context>
           }
         )
+        // Press Enter to confirm
+        form.addEventListener('submit', (e) => {
+          e.preventDefault()
+          if (submit()) {
+            modal?.close?.()
+          }
+        })
</code_context>
<issue_to_address>
**按 Enter 键不会提交表单**

当浏览器不会在没有提交按钮的情况下隐式提交表单时,由于该表单不包含提交按钮,因此要求默认提交按钮才能进行隐式提交的浏览器,在文本输入框中按下 Enter 键时不会派发 `submit` 事件。此监听器永远不会运行,页面也不会打开以供编辑。

向表单添加一个提交按钮(可以将其设为视觉隐藏),这样按下 Enter 键就会触发表单提交处理程序。
</issue_to_address>

Sourcery 评估

等待批准。 请先处理 1 个发现的问题。

阻塞性发现:packages/edit-any-page/src/index.ts:49


Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享它们 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/edit-any-page/src/index.ts" line_range="46-49" />
<code_context>
           }
         )
+        // Press Enter to confirm
+        form.addEventListener('submit', (e) => {
+          e.preventDefault()
+          if (submit()) {
+            modal?.close?.()
+          }
+        })
</code_context>
<issue_to_address>
**Enter does not submit the form**

When the browser does not implicitly submit a form without a submit button, the form contains no submit button, so browsers that require a default submit button for implicit submission do not dispatch a `submit` event when Enter is pressed in the text input. This listener never runs and the page is not opened for editing.

Add a submit button to the form (it can be visually hidden) so Enter activates the form submission handler.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: packages/edit-any-page/src/index.ts:49


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread packages/edit-any-page/src/index.ts Outdated
Comment on lines +46 to +49
form.addEventListener('submit', (e) => {
e.preventDefault()
if (submit()) {
modal?.close?.()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 高优先级 · 按 Enter 键不会提交表单

当浏览器不会在没有提交按钮的情况下隐式提交表单时,由于该表单不包含提交按钮,因此要求默认提交按钮才能进行隐式提交的浏览器,在文本输入框中按下 Enter 键时不会派发 submit 事件。此监听器永远不会运行,页面也不会打开以供编辑。

向表单添加一个提交按钮(可以将其设为视觉隐藏),这样按下 Enter 键就会触发表单提交处理程序。

给 AI Agent 的提示
在 `packages/edit-any-page/src/index.ts` 的第 46-49 行:

**按 Enter 键不会提交表单**

当浏览器不会在没有提交按钮的情况下隐式提交表单时,由于该表单不包含提交按钮,因此要求默认提交按钮才能进行隐式提交的浏览器,在文本输入框中按下 Enter 键时不会派发 `submit` 事件。此监听器永远不会运行,页面也不会打开以供编辑。

向表单添加一个提交按钮(可以将其设为视觉隐藏),这样按下 Enter 键就会触发表单提交处理程序。
Original comment in English

🟠 High · Enter does not submit the form

When the browser does not implicitly submit a form without a submit button, the form contains no submit button, so browsers that require a default submit button for implicit submission do not dispatch a submit event when Enter is pressed in the text input. This listener never runs and the page is not opened for editing.

Add a submit button to the form (it can be visually hidden) so Enter activates the form submission handler.

Prompt for AI agents
In `packages/edit-any-page/src/index.ts` at lines 46-49:

**Enter does not submit the form**

When the browser does not implicitly submit a form without a submit button, the form contains no submit button, so browsers that require a default submit button for implicit submission do not dispatch a `submit` event when Enter is pressed in the text input. This listener never runs and the page is not opened for editing.

Add a submit button to the form (it can be visually hidden) so Enter activates the form submission handler.

@dragon-fish

Copy link
Copy Markdown
Member Author

@claude 你可以安装 @inpageedit/core 依赖,确认一下接口类型是否正确,可能不需要复杂的 modal?.close?.() 守卫

@claude

claude Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Claude finished @dragon-fish's task in 20s —— View job


Couldn't verify the @inpageedit/core types

I couldn't install the dependencies, so I haven't checked the modal.confirm return type and made no code changes. The sandbox requires approval for pnpm install, and that approval wasn't granted. @inpageedit/core (^0.18.0) is already in the root package.json, so nothing needs adding. It just isn't installed in this checkout.

I didn't want to guess at the types, so I left the guard as it is. The current code at packages/edit-any-page/src/index.ts:33 is const modal: any = ctx.modal.confirm(...), followed by modal?.close?.(). The any annotation is probably what makes the guard necessary.

To unblock me, either:

  • add Bash(pnpm install:*) to --allowedTools and mention me again, or
  • check the type yourself. If confirm() returns a modal object with a non-optional close(), then:
    • drop the : any annotation, and
    • change modal?.close?.() to modal.close().

Sourcery's blocking comment says the form has no submit button, so pressing Enter won't fire submit. Browsers do implicitly submit a form with a single text input, even without a submit button. So the listener should run in practice, and the comment is likely a false positive. The HTML spec says a form with no submit button is implicitly submitted on Enter if it has only one field that blocks implicit submission, and a single text input qualifies. I haven't tested this in a browser.
· Branch: claude/issue-27-20261007-1420

@dragon-fish

Copy link
Copy Markdown
Member Author

@claude 给你加上了权限

@claude

claude Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Claude finished @dragon-fish's task in 28s —— View job


已按类型定义简化 modal 守卫

  • 安装依赖并检查 @inpageedit/core 类型
  • 去掉 : any 和 modal?.close?.() 守卫
  • 类型检查,并提交推送

结论: 在 @inpageedit/core@0.18.0 的 dist/index.d.ts 里,ModalService.confirm() 返回 IPEModal,而 IPEModal 有非可选的 close(): this。所以不需要复杂的守卫。

改动(packages/edit-any-page/src/index.ts,提交 61e8fc5):

  • const modal: any = ctx.modal.confirm(...) 改为 const modal = ctx.modal.confirm(...)
  • modal?.close?.() 改为 modal.close()

我跑了 tsc --noEmit,没有关于 edit-any-page 的报错。

关于 Sourcery 的「Enter 不会提交」意见: 我没改这部分,也没在浏览器里测试。按 HTML 规范,只有一个会阻止隐式提交的文本输入框的表单,即使没有提交按钮,按 Enter 也会触发 submit。所以我认为这条意见是误报。如果你在实际页面里发现 Enter 没反应,再加一个隐藏的提交按钮就行。
· Branch: claude/issue-27-20261007-1420

Co-authored-by: 机智的小鱼君 <44761872+dragon-fish@users.noreply.github.com>

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying ipe-plugin-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: 61e8fc5
Status: ✅  Deploy successful!
Preview URL: https://e6d2bd21.plugin-registry.pages.dev
Branch Preview URL: https://claude-issue-27-20261007-142.plugin-registry.pages.dev

View logs

@dragon-fish
dragon-fish merged commit 8b99082 into master Oct 7, 2026
2 of 3 checks passed
@dragon-fish
dragon-fish deleted the claude/issue-27-20261007-1420 branch October 7, 2026 14:45
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.

[Feature Request][edit-any-page] 打开弹窗时自动聚焦、按下回车时确认

1 participant