Skip to content

fix(InputMenu): stop adding new chip in ui in case not create mode - #6776

Open
al1maher wants to merge 1 commit into
nuxt:v4from
al1maher:fix/input-menu-visual-bug-chip
Open

fix(InputMenu): stop adding new chip in ui in case not create mode#6776
al1maher wants to merge 1 commit into
nuxt:v4from
al1maher:fix/input-menu-visual-bug-chip

Conversation

@al1maher

@al1maher al1maher commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #6760

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Stop creating a new chip in UI when the user searches and press Enter

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@al1maher
al1maher requested a review from benjamincanac as a code owner July 27, 2026 18:15
@github-actions github-actions Bot added the v4 #4488 label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

InputMenu.vue now intercepts Enter in the multi-tag input when createItem is disabled, preventing raw search text from being added as a chip. The template wires the Enter key event to the new handler.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title matches the main fix: preventing new chips from being added in non-create mode.
Description check ✅ Passed The description clearly describes the bug fix and the Enter-key behavior change in InputMenu.
✨ Finishing Touches
🧪 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/runtime/components/InputMenu.vue (1)

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

Add a regression test for disabled item creation.

Please cover Enter with multiple: true, a non-empty search term, and createItem: false, asserting that neither a chip nor an update:modelValue event is produced. Also verify that enabled createItem behavior remains unchanged.

🤖 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 `@src/runtime/components/InputMenu.vue` around lines 551 - 560, Add regression
coverage for onTagInputKeydown in the InputMenu tests: with multiple enabled, a
non-empty search term, and createItem false, pressing Enter must produce neither
a chip nor an update:modelValue event. Add a corresponding createItem true case
to confirm Enter still creates the tag and emits the expected model update.
🤖 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 `@src/runtime/components/InputMenu.vue`:
- Around line 551-560: Add regression coverage for onTagInputKeydown in the
InputMenu tests: with multiple enabled, a non-empty search term, and createItem
false, pressing Enter must produce neither a chip nor an update:modelValue
event. Add a corresponding createItem true case to confirm Enter still creates
the tag and emits the expected model update.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7fa69814-cbac-4d32-800e-d2a259aeb798

📥 Commits

Reviewing files that changed from the base of the PR and between 34554bf and 3c736a3.

📒 Files selected for processing (1)
  • src/runtime/components/InputMenu.vue

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/ui@6776

commit: 3c736a3

@benjamincanac benjamincanac changed the title fix(input-menu): stop adding new chip in ui in case not create mode fix(InputMenu): stop adding new chip in ui in case not create mode Jul 29, 2026
Comment on lines +551 to +560
function onTagInputKeydown(e: KeyboardEvent) {
if (e.key !== 'Enter') return

// reka-ui's TagsInputRoot adds the raw search text as a tag on Enter regardless of
// whether it matches a real item or createItem is enabled. Block that so
// we never render a chip that isn't reflected in modelValue.
if (!props.createItem) {
e.preventDefault()
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @al1maher! I don't think createItem is the right check though, the chip is still there with createItem: true and the menu closed. And preventing every Enter breaks form submission inside a UForm.

I think I would use searchTerm instead:

Suggested change
function onTagInputKeydown(e: KeyboardEvent) {
if (e.key !== 'Enter') return
// reka-ui's TagsInputRoot adds the raw search text as a tag on Enter regardless of
// whether it matches a real item or createItem is enabled. Block that so
// we never render a chip that isn't reflected in modelValue.
if (!props.createItem) {
e.preventDefault()
}
}
function onTagsInputKeydown(event: KeyboardEvent) {
if (event.isComposing || !searchTerm.value) {
return
}
event.preventDefault()
}

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think your approach is more correct, I made it that way as I was focusing on not breaking the create functionality but I think your solution is more robust

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

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UInputMenu visual bug with chip

2 participants