Skip to content

fix(file-upload): Fix the issue of accept failure when using EDM #3661

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

chenxi-20
Copy link
Collaborator

@chenxi-20 chenxi-20 commented Aug 22, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes
    • File Upload: The component now correctly honors the provided accept setting, ensuring only allowed file types can be selected when configured. Previously, it defaulted to an empty value, which could ignore the intended restriction.

@chenxi-20 chenxi-20 added the bug Something isn't working label Aug 22, 2025
Copy link

coderabbitai bot commented Aug 22, 2025

Walkthrough

The file upload component’s state initialization now sets state.accept from the incoming prop (props.accept) when provided, otherwise defaults to an empty string. No other files or logic paths are modified.

Changes

Cohort / File(s) Change Summary
File Upload State Defaults
packages/renderless/src/file-upload/vue.ts
In initState, state.accept default changed from '' to `props.accept

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at props that flow,
Now accept is set—just so!
From empty string to what you pass,
My forms hop swift, with proper class.
Carrot-quick tweaks, tidy and neat—
A nibble of change, complete! 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/upload-20250822

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

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

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/renderless/src/file-upload/vue.ts (2)

170-170: Prefer nullish coalescing (??) over logical OR (||).

props.accept ?? '' better reflects intent (only fallback on null/undefined), avoids edge-case falsy handling, and is idiomatic TS.

-    accept: props.accept || '',
+    accept: props.accept ?? '',

298-331: Keep state.accept in sync when the prop changes after mount.

If the parent dynamically updates accept (e.g., toggling allowed types), state.accept won’t update. Add a watcher.

   watch(
     () => props.action,
     () => {
       if (!props.httpRequest && !state.isEdm) {
         api.updateUrl()
       }
     },
     { immediate: true }
   )

+  // Keep internal state.accept aligned with external prop updates
+  watch(
+    () => props.accept,
+    (val) => {
+      state.accept = val ?? ''
+    },
+    { immediate: false }
+  )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4366672 and 77f1a4b.

📒 Files selected for processing (1)
  • packages/renderless/src/file-upload/vue.ts (1 hunks)
🔇 Additional comments (2)
packages/renderless/src/file-upload/vue.ts (2)

170-170: Good fix—hydrate state.accept from props to honor accept filtering (including EDM flows).

This addresses the empty accept state and ensures the input respects the consumer’s MIME/extensions filter.


293-294: Downstream state.accept binding confirmed

The EDM path correctly passes the updated state.accept through to the file input:

  • In packages/vue/src/file-upload/src/pc.vue, the uploadData.props.accept is set to
    isEdm ? accept : this.accept, where accept is the renderless state.accept value.
  • The Upload component (renderless) then uses props.accept when creating the <input> in its mounted hook (input.accept = props.accept || ''), ensuring the picker reflects state.accept for EDM cases.

No further changes are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant