Skip to content

feat: Added support for new input types and optimized the logic for showing and hiding elements.#56

Open
discreted66 wants to merge 1 commit into
mainfrom
lk-0710
Open

feat: Added support for new input types and optimized the logic for showing and hiding elements.#56
discreted66 wants to merge 1 commit into
mainfrom
lk-0710

Conversation

@discreted66

@discreted66 discreted66 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

feat:新增input类型支持,优化显隐逻辑

Summary by CodeRabbit

  • New Features
    • Added support for the input search field type (defaults to no type), including direct text entry and option-driven selection with radio-style panel behavior.
  • Bug Fixes
    • Improved dropdown/popover visibility and robustness during rapid open/close and tag creation.
    • Unified input/panel behavior (including search-option visibility and backup list handling) and removed special handling for the deprecated noValue type.
  • Documentation
    • Added an input example page and updated type references; replaced noValue with input.
  • Tests / Chores
    • Added Playwright and Vitest coverage for the updated behaviors; added a package test script and bumped version.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The search box replaces the documented noValue type with input, supports option-based and direct text entry, aligns input panels with radio behavior, improves dropdown timer handling, and adds documentation and automated coverage.

Changes

Input type support

Layer / File(s) Summary
Input contract and panel flow
packages/search-box/src/index.type.ts, packages/search-box/src/composables/use-dropdown.ts, packages/search-box/src/renderless.ts, packages/search-box/src/components/*.vue, packages/docs/search-box/input-type.*
The input type is added to the public contract, handled through standard selection logic, rendered like radio options when configured, and tested across option and direct-entry scenarios.
Dropdown lifecycle and validation
packages/search-box/src/utils/dropdown.ts, packages/search-box/__tests__/dropdown.spec.ts, packages/search-box/package.json
Dropdown timers are cleared before each visibility update, with coverage for dropdown and popover behavior and updated Vitest package configuration.
Documentation and navigation alignment
packages/docs/apis/types.md, packages/docs/search-box.js, packages/docs/guide/usage.md, packages/docs/.vitepress/config.mts, packages/docs/examples/input-type.md
Documentation and sidebar navigation describe input and remove the previous noValue references.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: kagol, zzcr

Poem

I’m a rabbit hopping through input lanes,
With radio stars and text-filled plains.
Timers clear, dropdowns glow,
New docs show the paths to go.
input tags leap—what a show!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding input-type support and refining show/hide behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lk-0710

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/search-box/src/renderless.ts`:
- Line 93: Update the computed property hasBackupList so option-less input
fields are not treated as requiring a backup list: gate the input case on
state.prevItem.options?.length or remove 'input' from the fallback types,
ensuring direct-entry inputs do not leave isLoading stuck on the loading state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6156685c-f01f-4cb9-b83f-a31fc3e09bcc

📥 Commits

Reviewing files that changed from the base of the PR and between 42e5dde and dcb3ccf.

📒 Files selected for processing (15)
  • packages/docs/.vitepress/config.mts
  • packages/docs/apis/types.md
  • packages/docs/examples/input-type.md
  • packages/docs/guide/usage.md
  • packages/docs/search-box.js
  • packages/docs/search-box/input-type.spec.ts
  • packages/docs/search-box/input-type.vue
  • packages/search-box/__tests__/dropdown.spec.ts
  • packages/search-box/package.json
  • packages/search-box/src/components/first-level-panel.vue
  • packages/search-box/src/components/second-level-panel.vue
  • packages/search-box/src/composables/use-dropdown.ts
  • packages/search-box/src/index.type.ts
  • packages/search-box/src/renderless.ts
  • packages/search-box/src/utils/dropdown.ts
💤 Files with no reviewable changes (1)
  • packages/search-box/src/composables/use-dropdown.ts

Comment thread packages/search-box/src/renderless.ts Outdated

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (3)
packages/docs/search-box/input-type.spec.ts (3)

78-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider splitting test 5 into two isolated tests

This test combines two distinct regression scenarios: (1) dropdown closes after option selection from a panel, and (2) dropdown closes after direct text entry. Combining them means a failure in the first half prevents the second half from running, making it harder to diagnose which regression returned. Splitting into two tests improves isolation and failure clarity.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/search-box/input-type.spec.ts` around lines 78 - 101, Split the
combined regression test into two independent tests: one covering dropdown
closure after selecting the “备注” option from the secondary panel, and another
covering dropdown closure after entering text for the “描述” field and pressing
Enter. Give each test its own setup/navigation and assertions so either scenario
runs and reports failures independently.

12-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fragile positional selectors with .nth(2)

The page.locator('div').filter({ hasText: /^备注$/ }).nth(2).click() pattern is used across nearly every test. Positional selectors like .nth(2) are brittle — any DOM restructuring (adding a wrapper, reordering panels) will silently break these tests with unclear failure messages.

Consider using more semantic selectors, such as scoping to the first-level panel container or using a data-testid attribute on the selectable field items.

Also applies to: 32-32, 47-47, 65-65, 87-87, 96-96, 112-112, 120-120

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/search-box/input-type.spec.ts` at line 12, Replace the fragile
positional selectors using page.locator('div').filter({ hasText: /^备注$/
}).nth(2) across the tests with stable semantic selectors, preferably by scoping
to the appropriate panel container or adding and targeting a data-testid on
selectable field items. Update all occurrences identified in the affected test
cases while preserving their click behavior.

4-4: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

pageerror assertion timing may miss post-test errors

The page.on('pageerror', (exception) => expect(exception).toBeNull()) pattern asserts inside the event callback. If a page error fires after the test body resolves but before Playwright tears down the page, the assertion may not be attributed to the correct test. A more robust pattern collects errors and asserts at the end:

const errors: string[] = []
page.on('pageerror', (e) => errors.push(e.message))
// ... test body ...
expect(errors).toEqual([])
♻️ Suggested pattern (apply to each test)
 test('input 输入型 - 有 options 时走 radio 面板选择', async ({ page }) => {
-  page.on('pageerror', (exception) => expect(exception).toBeNull())
+  const errors: string[] = []
+  page.on('pageerror', (e) => errors.push(e.message))
   await page.goto('/examples/input-type')
   // ... test body ...
+  expect(errors).toEqual([])
 })

Also applies to: 25-25, 39-39, 57-57, 79-79, 104-104

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/search-box/input-type.spec.ts` at line 4, Replace the inline
pageerror assertions in each affected test with an errors array collected via
the pageerror listener, then assert errors is empty at the end of the test body.
Apply this pattern consistently to all tests in input-type.spec.ts, ensuring the
final assertion occurs before the test completes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/docs/search-box/input-type.spec.ts`:
- Around line 78-101: Split the combined regression test into two independent
tests: one covering dropdown closure after selecting the “备注” option from the
secondary panel, and another covering dropdown closure after entering text for
the “描述” field and pressing Enter. Give each test its own setup/navigation and
assertions so either scenario runs and reports failures independently.
- Line 12: Replace the fragile positional selectors using
page.locator('div').filter({ hasText: /^备注$/ }).nth(2) across the tests with
stable semantic selectors, preferably by scoping to the appropriate panel
container or adding and targeting a data-testid on selectable field items.
Update all occurrences identified in the affected test cases while preserving
their click behavior.
- Line 4: Replace the inline pageerror assertions in each affected test with an
errors array collected via the pageerror listener, then assert errors is empty
at the end of the test body. Apply this pattern consistently to all tests in
input-type.spec.ts, ensuring the final assertion occurs before the test
completes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc9fbbb5-3979-4348-a642-0de98a313aea

📥 Commits

Reviewing files that changed from the base of the PR and between dcb3ccf and 40e13b6.

📒 Files selected for processing (15)
  • packages/docs/.vitepress/config.mts
  • packages/docs/apis/types.md
  • packages/docs/examples/input-type.md
  • packages/docs/guide/usage.md
  • packages/docs/search-box.js
  • packages/docs/search-box/input-type.spec.ts
  • packages/docs/search-box/input-type.vue
  • packages/search-box/__tests__/dropdown.spec.ts
  • packages/search-box/package.json
  • packages/search-box/src/components/first-level-panel.vue
  • packages/search-box/src/components/second-level-panel.vue
  • packages/search-box/src/composables/use-dropdown.ts
  • packages/search-box/src/index.type.ts
  • packages/search-box/src/renderless.ts
  • packages/search-box/src/utils/dropdown.ts
💤 Files with no reviewable changes (1)
  • packages/search-box/src/composables/use-dropdown.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/docs/.vitepress/config.mts
  • packages/docs/guide/usage.md
🚧 Files skipped from review as they are similar to previous changes (11)
  • packages/search-box/src/components/second-level-panel.vue
  • packages/docs/examples/input-type.md
  • packages/docs/apis/types.md
  • packages/search-box/tests/dropdown.spec.ts
  • packages/search-box/src/components/first-level-panel.vue
  • packages/search-box/package.json
  • packages/docs/search-box.js
  • packages/search-box/src/index.type.ts
  • packages/search-box/src/utils/dropdown.ts
  • packages/search-box/src/renderless.ts
  • packages/docs/search-box/input-type.vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant