Skip to content

Conversation

James-9696
Copy link
Collaborator

@James-9696 James-9696 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

  • New Features

    • Numeric input now supports touch interactions for incrementing and decrementing, improving mobile usability and aligning with keyboard behavior.
  • Bug Fixes

    • ActionSheet demo now closes reliably when Cancel or Confirm is tapped, ensuring consistent visibility control while keeping the opening behavior unchanged.

Copy link

coderabbitai bot commented Aug 22, 2025

Walkthrough

Two changes: the demo ActionSheet now controls visibility explicitly in cancel/confirm handlers instead of relying on update events; the mobile numeric input adds touchstart handlers on increase/decrease controls to trigger existing actions.

Changes

Cohort / File(s) Summary
ActionSheet demo visibility handling
packages/demos/app/actionsheet/custom-content.vue
Removed @update:visible binding; visibility now set manually. cancelFn and confirmFn explicitly set boxVisibility.value = false. Opening unchanged via function setting boxVisibility.value = true.
Mobile numeric touch support
packages/mobile/components/numeric/src/mobile.vue
Added touchstart.stop.prevent handlers on decrease/increase spans to call existing decrease/increase logic. No props/emits/public API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Demo as custom-content.vue
  participant Sheet as TinyActionSheet

  User->>Demo: Tap "Open"
  Demo->>Demo: boxVisibility = true
  Demo->>Sheet: Render with visible=true
  Sheet-->>User: Sheet visible

  alt User taps Cancel/Confirm
    User->>Demo: cancelFn()/confirmFn()
    Demo->>Demo: boxVisibility = false
    Demo->>Sheet: visible=false
    Sheet-->>User: Sheet closes
  end

  note over Demo,Sheet: No @update:visible binding<br/>Visibility managed solely by local state
Loading
sequenceDiagram
  autonumber
  actor User
  participant Numeric as Numeric Component

  par Decrease
    User->>Numeric: touchstart on "−"
    Numeric->>Numeric: decrease()
    Numeric-->>User: Value decremented
  and Increase
    User->>Numeric: touchstart on "+"
    Numeric->>Numeric: increase()
    Numeric-->>User: Value incremented
  end

  note over Numeric: Touch events mirror existing click/keyboard behavior
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws—new touches bloom,
A sheet now bows at my command, zoom!
Tap to open, tap to close,
Plus and minus on my nose—
Swift as carrots, crisp and neat,
Code hops forward, light on its feet. 🥕🐇

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 unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-problem-dev

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: 1

🧹 Nitpick comments (3)
packages/demos/app/actionsheet/custom-content.vue (2)

23-25: Remove unused ref.

activeName is declared but unused; trim it to keep the demo lean.

-const activeName = ref('')
 const boxVisibility = ref(false)

31-34: Type the confirm payload for clarity.

Add a type to msg so TS users see the expected shape when copying this demo.

-function confirmFn(msg) {
+function confirmFn(msg: unknown) {
   console.log('确定:', msg)
 }

If you know the ActionSheet’s confirm payload type (e.g., string | number), use that instead of unknown.

packages/mobile/components/numeric/src/mobile.vue (1)

25-35: Improve accessibility: make controls focusable and reflect disabled state.

Spans with role="button" aren’t tabbable by default; add tabindex and aria-disabled so keyboard and AT users can operate them.

     <span
       class="tiny-mobile-numeric__decrease"
       role="button"
+      :tabindex="state.minDisabled ? -1 : 0"
+      :aria-disabled="String(state.minDisabled)"
       v-if="controls"
       v-repeat-click="decrease"
       :class="{ 'is-disabled': state.minDisabled }"
       @keydown.enter="decrease"
@@
     <span
       class="tiny-mobile-numeric__increase"
       role="button"
+      :tabindex="state.maxDisabled ? -1 : 0"
+      :aria-disabled="String(state.maxDisabled)"
       v-if="controls"
       v-repeat-click="increase"
       :class="{ 'is-disabled': state.maxDisabled }"
       @keydown.enter="increase"

Also applies to: 36-46

📜 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 52daecb and c543772.

📒 Files selected for processing (2)
  • packages/demos/app/actionsheet/custom-content.vue (1 hunks)
  • packages/mobile/components/numeric/src/mobile.vue (2 hunks)
🔇 Additional comments (1)
packages/demos/app/actionsheet/custom-content.vue (1)

4-8: I’ve added a script to confirm the current binding in custom-content.vue and compare it against ellipsis.vue which uses two-way visibility sync. Let me know the results so we can finalize the review recommendation.

Comment on lines +32 to 33
@touchstart.stop.prevent="decrease"
>
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Touch handler can double-fire and may bypass disabled logic; unify input path and guard.

  • Risk of double invoke on some devices if v-repeat-click also listens to touch/pointer.
  • Directly calling decrease/increase here can bypass any disabled checks the directive might enforce.

Option 1 — Keep touchstart but guard disabled:

-      @touchstart.stop.prevent="decrease"
+      @touchstart.stop.prevent="state.minDisabled ? void 0 : decrease()"
@@
-      @touchstart.stop.prevent="increase"
+      @touchstart.stop.prevent="state.maxDisabled ? void 0 : increase()"

Option 2 — Prefer pointer events (covers mouse/stylus/touch) and guard:

-      @touchstart.stop.prevent="decrease"
+      @pointerdown.stop.prevent="state.minDisabled ? void 0 : decrease()"
@@
-      @touchstart.stop.prevent="increase"
+      @pointerdown.stop.prevent="state.maxDisabled ? void 0 : increase()"

Follow-up:

  • If v-repeat-click can be updated to use pointer events and handle disabled internally, consider removing these inline handlers to avoid divergent paths. I can draft that change if helpful.

Also applies to: 43-44


🏁 Script executed:

#!/bin/bash
# Display context around the handlers in mobile.vue (lines 1-100)
sed -n '1,100p' packages/mobile/components/numeric/src/mobile.vue

# Find all occurrences of the custom directive and its usage
rg -n "repeat-click" -C3

Length of output: 5132


🏁 Script executed:

#!/bin/bash
# Locate the repeat-click directive implementation
find packages -type f | grep -E "repeat-click\\.(js|ts)$"

Length of output: 101


🏁 Script executed:

#!/bin/bash
# Show the beginning of the repeat-click directive implementation
sed -n '1,200p' packages/mobile/utils/deps/repeat-click.ts

# Inspect which events are registered by the directive
rg -n "addEventListener" -C2 packages/mobile/utils/deps/repeat-click.ts

# Check for touch/pointer handling in the directive
rg -n "touch" -C2 packages/mobile/utils/deps/repeat-click.ts
rg -n "pointer" -C2 packages/mobile/utils/deps/repeat-click.ts

# Look for disabled logic within the directive
rg -n "disabled" -C2 packages/mobile/utils/deps/repeat-click.ts

Length of output: 1436


Unify pointer & touch event handling and enforce disabled guard in numeric controls

Verified that the v-repeat-click directive in packages/mobile/utils/deps/repeat-click.ts only listens for mouse (mousedown/mouseup) and does not check for a disabled state, while the inline @touchstart handlers in the Vue template invoke decrease/increase unconditionally. This can lead to:

  • Double-fire on touch devices that emit a synthetic mousedown after touchstart.
  • Bypassing disabled logic, since neither the directive nor the inline handlers respect state.minDisabled/state.maxDisabled.

Recommendations:

  1. Refactor v-repeat-click to use pointer events and honor disabled state
    Update packages/mobile/utils/deps/repeat-click.ts to register pointerdown/pointerup and short-circuit when the control is disabled:

    // packages/mobile/utils/deps/repeat-click.ts
    - on(el, 'mousedown', (e) => {
    + on(el, 'pointerdown', (e) => {
        if (e.button !== 0) {
          return
        }
    +   if (el.classList.contains('is-disabled')) {
    +     return
    +   }
        startTime = Date.now()
        once(document, 'mouseup', clear)
        clearInterval(interval)
        interval = setInterval(handler, LONG_PRESS_INTERVAL)
      })

    Once the directive handles both mouse and touch (via pointer events) and respects the disabled state, you can remove the inline touch handlers below.

  2. Quick inline-guard fix (if directive refactor isn’t immediate)
    Change the touch handlers in packages/mobile/components/numeric/src/mobile.vue to use pointerdown and skip when disabled:

    --- a/packages/mobile/components/numeric/src/mobile.vue
    +++ b/packages/mobile/components/numeric/src/mobile.vue
      <span
        class="tiny-mobile-numeric__decrease"
        role="button"
        v-if="controls"
        v-repeat-click="decrease"
        :class="{ 'is-disabled': state.minDisabled }"
    -   @touchstart.stop.prevent="decrease"
    +   @pointerdown.stop.prevent="state.minDisabled ? void 0 : decrease()"
      >
      …
      <span
        class="tiny-mobile-numeric__increase"
        role="button"
        v-if="controls"
        v-repeat-click="increase"
        :class="{ 'is-disabled': state.maxDisabled }"
    -   @touchstart.stop.prevent="increase"
    +   @pointerdown.stop.prevent="state.maxDisabled ? void 0 : increase()"
      >

    This ensures both mouse and touch go through the same guard and prevents unintentional calls when disabled.

Affected locations:

  • packages/mobile/components/numeric/src/mobile.vue — lines ~32–33 and ~43–44
  • packages/mobile/utils/deps/repeat-click.ts

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
packages/mobile/components/numeric/src/mobile.vue around lines 32–33 (and
similarly ~43–44): the inline @touchstart handlers fire unconditionally and can
double-trigger with mouse events and bypass disabled guards; replace the inline
touch handlers with pointerdown (or remove them after the directive update) and
short-circuit when appropriate by checking state.minDisabled/state.maxDisabled
before calling decrease/increase so disabled controls are honored; additionally
update packages/mobile/utils/deps/repeat-click.ts to listen to
pointerdown/pointerup (instead of mousedown/mouseup), consult the element's
disabled state (or a provided binding) and return early when disabled so the
directive and inline handlers share the same pointer-based behavior and disabled
guard.

@James-9696 James-9696 changed the title fix: update problem fix(numeric): update demo problem and numeric event Sep 2, 2025
@zzcr zzcr merged commit e97c839 into dev Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants