Skip to content

fix: fix IconPicker props warning #6108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged

Conversation

ming4762
Copy link
Contributor

@ming4762 ming4762 commented May 4, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved event handling in the icon picker to ensure updates are properly propagated and duplicate event triggers are avoided.

Invalid prop: type check failed for prop "onUpdate:value". Expected Function, got Array
Copy link

changeset-bot bot commented May 4, 2025

⚠️ No Changeset found

Latest commit: 2b85ef5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 4, 2025

Walkthrough

The changes update the icon picker Vue component to improve how it handles event propagation and attribute binding. The component now uses Vue's useAttrs to access incoming attributes and specifically manages the onUpdate:<modelValueProp> event handler, ensuring it is called only if present and is a function. A computed property is introduced to omit this event handler from the attributes bound to the input, preventing duplicate event handling. The template is updated to use this refined set of attributes, and relevant utility functions and imports are added to support these changes.

Changes

File(s) Change Summary
packages/effects/common-ui/src/components/icon-picker/icon-picker.vue Refactored to use useAttrs for attribute management, added computed property to omit specific event handler, updated event propagation logic, and adjusted template bindings.

Sequence Diagram(s)

sequenceDiagram
    participant ParentComponent
    participant IconPicker
    participant InputComponent

    ParentComponent->>IconPicker: Passes attributes (including onUpdate:modelValue)
    IconPicker->>InputComponent: Binds attributes (excluding onUpdate:modelValue)
    InputComponent->>IconPicker: Triggers value update
    IconPicker->>ParentComponent: Calls onUpdate:modelValue if provided
Loading

Poem

In the garden of code where icons bloom bright,
A picker now listens with attributes light.
No double events, just a single clear call—
The rabbit ensures no echoes at all.
With Vue’s gentle touch and a hop of delight,
The picker now works just right!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f94ca10 and 2b85ef5.

📒 Files selected for processing (1)
  • packages/effects/common-ui/src/components/icon-picker/icon-picker.vue (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Check (windows-latest)
  • GitHub Check: Check (ubuntu-latest)
  • GitHub Check: Lint (windows-latest)
  • GitHub Check: Test (windows-latest)
  • GitHub Check: Lint (ubuntu-latest)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: post-update (windows-latest)
  • GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (6)
packages/effects/common-ui/src/components/icon-picker/icon-picker.vue (6)

4-4: Good addition of the useAttrs API.

Adding useAttrs is the correct approach to access the component's attributes within the setup function, allowing proper handling of attribute binding.


25-27: Good utility imports to support attribute handling.

The isFunction utility is appropriate for type checking event handlers, and objectOmit is the right tool for filtering out specific attributes from the binding.


68-69: Proper implementation of useAttrs.

Correctly accessing the component's attributes through the Composition API, which will allow selective binding in the template.


171-177: Good fix for event propagation.

The update to updateCurrentSelect now properly checks if the update event handler exists in the attributes and calls it if it's a function. This ensures the event is correctly propagated to the parent component.


178-180: Excellent solution to prevent duplicate event binding.

Creating a computed property that omits the onUpdate:${modelValueProp} attribute is the correct approach to prevent the event handler from being bound twice.


202-202: Perfect implementation of selective attribute binding.

Using v-bind="getBindAttrs" instead of directly binding all attributes ensures that the onUpdate:${modelValueProp} event handler is not bound twice, which resolves the props warning.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@anncwb anncwb merged commit 3b3f8e4 into vbenjs:main May 6, 2025
14 checks passed
@ming4762 ming4762 deleted the 2025050402 branch May 6, 2025 07:12
mynetfan pushed a commit that referenced this pull request May 19, 2025
Invalid prop: type check failed for prop "onUpdate:value". Expected Function, got Array
baohaojie123 added a commit to baohaojie123/vue-vben-admin that referenced this pull request Jun 4, 2025
* 'main' of https://github.com/baohaojie123/vue-vben-admin:
  fix: fix `IconPicker` props warning (vbenjs#6108)
  chore: remove prepare script from package.json
  chore: update prepare script in package.json to remove lefthook installation
  feat(project): migrate from husky and lint-staged to lefthook (vbenjs#6104)
  feat: support smooth auto-scroll to active menu item (vbenjs#6102)
  chore: close eslint object sorting (vbenjs#6101)
  refactor: modify the default homepage path loaded from the preference… (vbenjs#6099)
  fix: add triggerClass binding to PopoverTrigger and update icon-picker styles (vbenjs#6095)
  fix: add missing translation for preferences drawer (vbenjs#6094)
  fix: destroyOnClose incorrect default value, fixed vbenjs#6092 (vbenjs#6093)
  fix: fix `LoginExpiredModal` in some cases, `message` may be obscured (vbenjs#6086)
  fix:  show validation message as tooltip in compact form (vbenjs#6087)
  perf: page componet supports custom height offset for flexible content height … (vbenjs#6081)

# Conflicts:
#	apps/web-antd/src/adapter/component/index.ts
#	apps/web-antd/src/router/guard.ts
#	apps/web-antd/src/router/routes/core.ts
#	apps/web-antd/src/store/auth.ts
#	apps/web-naive/src/adapter/component/index.ts
#	apps/web-naive/src/router/guard.ts
#	apps/web-naive/src/router/routes/core.ts
#	apps/web-naive/src/store/auth.ts
#	docs/src/en/guide/essentials/development.md
#	docs/src/en/guide/essentials/settings.md
#	docs/src/en/guide/other/faq.md
#	docs/src/en/guide/project/standard.md
#	docs/src/guide/essentials/development.md
#	docs/src/guide/essentials/settings.md
#	docs/src/guide/other/faq.md
#	docs/src/guide/project/standard.md
#	pnpm-lock.yaml
#	pnpm-workspace.yaml
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants