Skip to content

Conversation

@webvs2
Copy link
Contributor

@webvs2 webvs2 commented Dec 5, 2025

Custom send button disabled for sending

Summary by CodeRabbit

  • New Features

    • Sender now accepts an optional external control for the send button’s disabled state; when provided it determines whether sending is allowed, otherwise existing behavior (based on input and loading) is preserved.
    • Send action now evaluates the final send decision using the external override when present.
  • Chores

    • Minor formatting cleanup (trailing newline).

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Dec 5, 2025

Deploy Preview for antd-design-x-vue ready!

Name Link
🔨 Latest commit aca8b77
🔍 Latest deploy log https://app.netlify.com/projects/antd-design-x-vue/deploys/693eb16a8db269000899a1f8
😎 Deploy Preview https://deploy-preview-458--antd-design-x-vue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Walkthrough

Added an optional boolean prop sendDisabled to the Sender component and its interface. Sender's trigger logic now checks sendDisabled (when provided) to decide whether to send and exposes the disabled state via onSendDisabled; a newline was added to a hook file with no behavioral change.

Changes

Cohort / File(s) Summary
Props / Interface
src/sender/interface.ts
Added optional sendDisabled?: boolean to SenderProps.
Component implementation
src/sender/Sender.vue
Added public sendDisabled prop; updated triggerSend to compute shouldSend/isSend using sendDisabled when defined (fallback to internal state), and adjusted onSendDisabled mapping accordingly.
Formatting cleanup
src/sender/useSpeech.ts
Trailing newline added after return (no functional change).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus review on src/sender/Sender.vue (prop typing, computed isSend logic, event/callback exposure).
  • Verify src/sender/interface.ts change is compatible with consumers and builds.
  • Quick lint/format check for useSpeech.ts.

Possibly related PRs

Suggested reviewers

  • wzc520pyfm

Poem

🐰 I nudged a button, soft and spry,
A prop now tells if the hop's allowed to fly.
Say "disabled" and I'll patiently stay,
Or let my inner hop send words away.
Tiny change, cheerful thump — hooray! 🥕

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(sender): add sendDisabled prop' directly and accurately describes the main change: adding a new sendDisabled prop to the Sender component.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 27119df and aca8b77.

📒 Files selected for processing (1)
  • src/sender/Sender.vue (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/sender/Sender.vue

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 and usage tips.

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/sender/Sender.vue (1)

38-68: Fix inverted boolean semantics for SendDisabled in onSendDisabled

Currently the disabled state is computed as:

const {
  // ...
  onSubmit,
  SendDisabled,
  // ...
} = defineProps<SenderProps>();

// ...

const actionsButtonContextProps = computed(() => ({
  prefixCls: actionBtnCls.value,
  onSend: triggerSend,
  onSendDisabled: SendDisabled ? !SendDisabled() : !innerValue.value,
  // ...
}));

Given the PR description (“custom send button disabled state”) and the prop name SendDisabled?: () => boolean, callers will naturally implement SendDisabled() to return true when the button should be disabled. The current !SendDisabled() inverts that:

  • SendDisabled() returns trueonSendDisabled becomes false → send button effectively enabled.
  • SendDisabled() returns falseonSendDisabled becomes true → send button disabled.

This is almost certainly backwards for a “Disabled” API.

You can fix the semantics while preserving the fallback by using the function value directly:

 const actionsButtonContextProps = computed(() => ({
   prefixCls: actionBtnCls.value,
   onSend: triggerSend,
-  onSendDisabled: SendDisabled ? !SendDisabled() : !innerValue.value,
+  // If provided, SendDisabled() should return the actual disabled state.
+  onSendDisabled: SendDisabled ? SendDisabled() : !innerValue.value,
   onClear: triggerClear,
   onClearDisabled: !innerValue.value,
   onCancel,
   onCancelDisabled: !loading,
   onSpeech: () => triggerSpeech(false),
   onSpeechDisabled: !speechPermission.value,
   speechRecording: speechRecording.value,
   disabled,
 }));

(Separately, see the comment in src/sender/interface.ts about renaming this prop to camelCase sendDisabled for consistency and template usability.)

Also applies to: 281-293

🧹 Nitpick comments (1)
src/sender/interface.ts (1)

44-90: Consider renaming SendDisabled prop to camelCase sendDisabled

SenderProps uses camelCase for all props (submitType, allowSpeech, autoSize, etc.), but this new prop is PascalCase:

SendDisabled?: () => boolean;

Two concerns:

  • API consistency: A PascalCase prop stands out against all other camelCase props and is easy to misuse.
  • Template binding: In Vue templates, send-disabled normalizes to sendDisabled, not SendDisabled, so template users will likely be unable to bind this prop without TSX/JSX, which defeats the purpose of a public API.

Before release, I’d strongly suggest normalizing this:

-export interface SenderProps {
+export interface SenderProps {
@@
-  disabled?: boolean;
-  SendDisabled?: () => boolean;
+  disabled?: boolean;
+  sendDisabled?: () => boolean;

…and updating the corresponding usage in Sender.vue (destructuring and actionsButtonContextProps) to sendDisabled as well.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8950c8 and 316433c.

📒 Files selected for processing (3)
  • src/sender/Sender.vue (2 hunks)
  • src/sender/interface.ts (1 hunks)
  • src/sender/useSpeech.ts (1 hunks)
🔇 Additional comments (1)
src/sender/useSpeech.ts (1)

148-150: Formatting-only change; behavior unchanged

The added trailing newline after the return has no impact on runtime behavior. The hook’s logic and API remain intact.

@wzc520pyfm wzc520pyfm changed the title add SendDisabled api feat(sender): add sendDisabled prop Dec 14, 2025
Copy link
Contributor

@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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 316433c and 27119df.

📒 Files selected for processing (2)
  • src/sender/Sender.vue (3 hunks)
  • src/sender/interface.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/sender/interface.ts
🧰 Additional context used
🪛 GitHub Actions: ci
src/sender/Sender.vue

[error] 175-175: TS2322: Type '(message: string) => void' is not assignable to type 'boolean'.

🪛 GitHub Check: ci
src/sender/Sender.vue

[failure] 175-175:
Type '(message: string) => void' is not assignable to type 'boolean'.

🔇 Additional comments (1)
src/sender/Sender.vue (1)

51-51: LGTM! Prop declaration is correct.

The sendDisabled prop is properly declared and will allow external control of the send button's disabled state.

Copy link
Owner

@wzc520pyfm wzc520pyfm left a comment

Choose a reason for hiding this comment

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

Great!

@wzc520pyfm wzc520pyfm merged commit 9ea3998 into wzc520pyfm:main Dec 15, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【Sender】 在某些情况下,即使文本内容为空, 仍希望能触发 onSubmit

2 participants