Skip to content

fix: modify the issue of radio and checkbox components being unclickable - #37

Merged
zzcr merged 9 commits into
devfrom
fix-test-radio
Sep 11, 2025
Merged

fix: modify the issue of radio and checkbox components being unclickable#37
zzcr merged 9 commits into
devfrom
fix-test-radio

Conversation

@James-9696

@James-9696 James-9696 commented Sep 10, 2025

Copy link
Copy Markdown
Collaborator

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

    • Demo now includes a checkbox group with default selection and real-time display of chosen values.
  • Style

    • Improved mobile Radio and Checkbox tap targets for easier selection.
    • Added horizontal layout styling for checkbox groups.
  • Refactor

    • Minor accessibility and keyboard interaction improvements for mobile Radio.
    • Formatting cleanups with no behavior change.
  • Chores

    • Version updates for mobile and theme packages.

@coderabbitai

coderabbitai Bot commented Sep 10, 2025

Copy link
Copy Markdown

Walkthrough

Updates demo to include a checkbox group with reactive selection. Adjusts mobile radio component accessibility and keyboard event propagation. Introduces heatmap sizing variables and styling for checkbox and radio inputs. Bumps package versions for mobile and theme-mobile. Minor formatting changes in renderless logic without behavior changes.

Changes

Cohort / File(s) Summary
Demo: Add checkbox group
packages/demos/app/radio/event.vue
Adds TinyCheckboxGroup with v-model checked, displays selected values, imports TinyCheckbox/Group, adds spacing and .demo-checkbox-group styles.
Mobile Radio component tweaks
packages/mobile/components/radio/src/mobile.vue, packages/mobile/components/radio/src/renderless/index.ts
mobile.vue: removes aria-hidden="true" on input; allows keydown to propagate by removing inner @keydown.stop; formatting adjustments. renderless/index.ts: trailing newline only.
Checkbox styles and vars (theme)
packages/theme-mobile/src/checkbox/index.less, packages/theme-mobile/src/checkbox/vars.less
index.less: .checkbox width 100%; &__original uses inset: 0, heatmap width/height vars, opacity: 0, z-index: 2. vars.less: adds --tvm-Checkbox-heatmap-width/height.
Radio styles and vars (theme)
packages/theme-mobile/src/radio/index.less, packages/theme-mobile/src/radio/vars.less
index.less: &__original switches to inset: 0, sets heatmap width/height, z-index: 1. vars.less: adds --tvm-Radio-heatmap-width/height.
Version bumps
packages/mobile/package.json, packages/theme-mobile/package.json
Version updated from 1.0.0-alpha.11 to 1.0.0-alpha.11.5.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (2 passed, 1 inconclusive)

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description Check ❓ Inconclusive The current description consists solely of a generic PR template checklist and does not describe the specific issue being fixed or how the changes address the unclickable components, making it too vague to convey meaningful information about the changeset. Please update the PR description to include a concise summary of the unclickable behavior in the radio and checkbox components, describe how this patch resolves that issue, and reference any relevant issue numbers or test results.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately reflects the primary purpose of the changeset, which is to fix the unclickable behavior of the radio and checkbox components, and it clearly summarizes the main change from the developer’s perspective.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

I twitch my ears at version chimes,
New checkboxes dance in tidy lines.
Radios whisper, keys now flow,
Heatmaps widen, softly glow.
I thump with joy—hop, hop, hooray!
Styles aligned, we ship today. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ 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-test-radio

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
packages/mobile/components/radio/src/mobile.vue (1)

31-43: A11Y regression: removing aria-hidden from the hidden input creates duplicate controls for SR

The label has role="radio" and handles focus/keyboard. Without aria-hidden, screen readers will also expose the native input (even with tabindex="-1"), leading to duplicate announcements. Restore aria-hidden on the input (or drop the custom role and rely on the native input).

Minimal fix:

      <input
        ref="radio"
        class="tiny-mobile-radio__original"
        :value="label"
        type="radio"
        v-model="state.model"
        @focus="state.focus = true"
        @blur="state.focus = false"
        @change="handleChange"
        :name="name"
        :disabled="state.isDisabled"
        tabindex="-1"
+       aria-hidden="true"
      />

Alternative (bigger change): remove role/aria-* from the label, set tabindex="0" on the input, and use the native control for accessibility.

🧹 Nitpick comments (4)
packages/theme-mobile/src/radio/index.less (1)

140-144: Clickable heatmap fix makes sense; avoid over‑constraining with inset + width/height

Raising z-index and adding explicit heatmap sizing should restore clickability. Minor: using inset: 0 together with explicit width/height over-constrains absolute positioning; prefer anchoring with top/left only to avoid inconsistent UA resolution.

Apply:

   &__original {
     opacity: 0;
     outline: 0;
     position: absolute;
-    z-index: 1;
-    inset: 0;
-    width: var(--tvm-Radio-heatmap-width);
-    height: var(--tvm-Radio-heatmap-height);
+    z-index: 1;
+    top: 0;
+    left: 0;
+    width: var(--tvm-Radio-heatmap-width);
+    height: var(--tvm-Radio-heatmap-height);
     margin: 0;
   }
packages/demos/app/radio/event.vue (2)

7-12: Demo addition is clear; avoid
for spacing

Prefer CSS margins over
for layout spacing in demos.

-    <br/> <br/>
+    <!-- spacing handled by CSS -->

And add (or reuse) a margin above the group:

 .demo-checkbox-group {
   display: flex;
   justify-content: flex-start;
   flex-wrap: nowrap;
   width: 200px;
+  margin-top: 16px;
 }

25-27: Fix param shadowing in changeAction

Avoid shadowing outer value. Rename the parameter.

-function changeAction(value) { // NISVUE3 FIXME: value重复定义,请手工修改
-  text.value = value === '1' ? '男' : '女'
+function changeAction(newValue) { // NISVUE3 FIXME resolved
+  text.value = newValue === '1' ? '男' : '女'
 }
packages/theme-mobile/src/checkbox/index.less (1)

22-23: Adding width: 100% changes layout; verify group alignment and overflow.

Setting the root checkbox container to width: 100% while it remains display: inline-block can force full-row occupancy and may make margin-right ineffective or cause unexpected horizontal spacing in groups. Please verify:

  • Checkbox groups (inline demos) don’t regress into unintended stacking or horizontal scroll.
  • Long labels still wrap as expected given root white-space: nowrap and label white-space: pre-wrap.

If the intent is a full-row tap target, consider switching the root to block and neutralizing the right margin for cleaner layout.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e97c839 and b618e57.

📒 Files selected for processing (9)
  • packages/demos/app/radio/event.vue (1 hunks)
  • packages/mobile/components/radio/src/mobile.vue (2 hunks)
  • packages/mobile/components/radio/src/renderless/index.ts (1 hunks)
  • packages/mobile/package.json (1 hunks)
  • packages/theme-mobile/package.json (1 hunks)
  • packages/theme-mobile/src/checkbox/index.less (2 hunks)
  • packages/theme-mobile/src/checkbox/vars.less (1 hunks)
  • packages/theme-mobile/src/radio/index.less (1 hunks)
  • packages/theme-mobile/src/radio/vars.less (1 hunks)
🔇 Additional comments (10)
packages/theme-mobile/package.json (1)

3-3: Approve version bump for theme-mobile

theme-mobile (1.0.0-alpha.11.5) now matches vue-mobile; ensure the changelog/tag for 1.0.0-alpha.11.5 exists and that the build pipeline publishes both packages together.

packages/mobile/package.json (1)

4-4: Confirm versions are in lockstep Both @opentiny/vue-mobile and @opentiny/vue-theme-mobile are at 1.0.0-alpha.11.5; ensure you publish them atomically to avoid mismatched installs.

packages/mobile/components/radio/src/renderless/index.ts (1)

106-107: No-op change

Only a trailing newline added. No behavior impact.

packages/mobile/components/radio/src/mobile.vue (2)

22-24: Space key handling on the label is correct

Keeping Space to toggle radios matches ARIA Authoring Practices. LGTM.


45-47: Allowing keydown to bubble from label text is good

Removing keydown.stop on the label text ensures keyboard events reach the label handler. Nice.

packages/theme-mobile/src/checkbox/vars.less (1)

38-41: Heatmap variables added—good for consistency and theming

Consistent with radio vars. No concerns.

packages/theme-mobile/src/radio/vars.less (1)

24-27: Heatmap size variables added—LGTM

Matches the checkbox pattern; enables design tuning without code changes.

packages/demos/app/radio/event.vue (2)

18-18: Imports are correct and minimal

Using TinyCheckbox and TinyCheckboxGroup alongside TinyRadio reads well.


22-22: Good: v-model default for checked

Initializing to an array demonstrates group binding clearly.

packages/theme-mobile/src/checkbox/index.less (1)

85-95: Heatmap custom properties defined and used consistently
Checkbox and radio both declare --tvm-*-heatmap-width/-height in their vars.less and apply them to the &__original overlays in index.less.

Comment on lines +89 to 94
inset: 0;
width: var(--tvm-Checkbox-heatmap-width);
height: var(--tvm-Checkbox-heatmap-height);
opacity: 0;
z-index: 2;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Over-constrained absolute positioning and duplicate opacity; simplify the hit-area overlay.

Using inset: 0 together with explicit width/height can over-constrain absolutely positioned elements and may not yield the intended full-row “heatmap.” Also, opacity: 0 is duplicated (Line 86 and Line 92). Recommend relying solely on inset: 0 to cover the entire container and remove the duplicate property.

Apply this diff:

-    inset: 0;
-    width: var(--tvm-Checkbox-heatmap-width);
-    height: var(--tvm-Checkbox-heatmap-height);
-    opacity: 0;
-    z-index: 2;    
+    inset: 0;
+    z-index: 2;

Result: the invisible input fully overlays the component, maximizing clickability across icon + label without layout surprises.


🏁 Script executed:

#!/bin/bash
# Locate the checkbox LESS file
FILE=$(find . -type f -path '*/packages/theme-mobile/src/checkbox/index.less')
# Print lines 1–120 for context
sed -n '1,120p' "$FILE"
# Show all opacity declarations with line numbers
rg -n 'opacity' "$FILE"
# Show inset, width, and height declarations
rg -nE 'inset:|width:|height:' "$FILE"

Length of output: 3261


Simplify hit-area overlay in &__original
Remove redundant width, height and duplicate opacity: 0, and rely on inset: 0 to fully cover the container while preserving z-index: 2.

-    inset: 0;
-    width: var(--tvm-Checkbox-heatmap-width);
-    height: var(--tvm-Checkbox-heatmap-height);
-    opacity: 0;
-    z-index: 2;    
+    inset: 0;
+    z-index: 2;

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

🤖 Prompt for AI Agents
In packages/theme-mobile/src/checkbox/index.less around lines 89 to 94, the
&__original hit-area overlay contains redundant declarations (explicit width and
height plus a duplicated opacity: 0) even though inset: 0 already covers the
container; remove the width and height properties and the duplicate opacity
declaration, leaving only inset: 0 and z-index: 2 (and a single opacity: 0 if
needed) so the overlay is simplified and behavior is preserved.

@zzcr
zzcr merged commit a527d70 into dev Sep 11, 2025
1 check passed
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