Skip to content

fix: prevent tour actions from submitting forms - #110

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/tour-action-button-types
Open

fix: prevent tour actions from submitting forms#110
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/tour-action-button-types

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • mark the default Prev, Next, and Finish controls as type="button"
  • add rendered-type assertions to the existing navigation regression
  • update the affected snapshots

Why

Native <button> elements default to type="submit". When a Tour popup is mounted into a form through a custom popup container, using its built-in navigation can therefore submit the unrelated form. The Close control already uses type="button"; this makes every default Tour action consistent and non-submitting.

Verification

  • exact-base regression: 33 tests passed / 1 failed because Prev had no type
  • fixed full suite: 2/2 suites, 34/34 tests, 16/16 snapshots passed
  • TypeScript: passed
  • ESLint: 0 errors (2 existing useTarget hook warnings)
  • focused source formatting and git diff --check: passed

AI assistance disclosure: Codex assisted with current-master tracing, open-PR overlap checks, regression execution, and drafting. I verified the behavior, patch, snapshots, and results.

Summary by CodeRabbit

  • Bug Fixes

    • 优化导览流程中的“上一页”“下一页”和“完成”按钮行为,避免按钮在表单场景下触发意外提交。
  • Tests

    • 增加对上述按钮类型的自动化验证,确保导航和完成操作正常运行。

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fe872e05-b822-4d83-9198-7dafc9641d2c

📥 Commits

Reviewing files that changed from the base of the PR and between 1cd4d96 and 3861f62.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/index.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/TourStep/DefaultPanel.tsx
  • tests/index.test.tsx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

导航面板的上一页、下一页和完成按钮新增 type="button"。基础测试获取这些按钮并验证类型属性,同时保持原有导航点击流程。

Changes

导航按钮类型更新

Layer / File(s) Summary
按钮类型与测试验证
src/TourStep/DefaultPanel.tsx, tests/index.test.tsx
导航按钮新增 type="button",原有渲染条件和点击回调保持不变。基础测试验证 Prev、Next 和 Finish 按钮的类型属性。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 3861f

The default Tour navigation controls now avoid submitting containing forms, with regression coverage and validation passing; no actionable merge-blocking risk remains beyond normal checks and review.

Poem

小兔看见按钮排成行
Prev、Next、Finish 都换上新牌
type="button" 轻轻写好
测试逐个确认不出错
胡萝卜也为这次更新鼓掌

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:为导览操作按钮添加 type="button",防止按钮在表单中提交表单。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant