Skip to content

fix: Radio の選択ドットが label の padding で位置ずれしないようにする#19

Open
ryoshin0830 wants to merge 1 commit into
pepabo:mainfrom
ryoshin0830:fix/radio-dot-padding-safe
Open

fix: Radio の選択ドットが label の padding で位置ずれしないようにする#19
ryoshin0830 wants to merge 1 commit into
pepabo:mainfrom
ryoshin0830:fix/radio-dot-padding-safe

Conversation

@ryoshin0830

Copy link
Copy Markdown

概要

Radio のルート(label)に padding を当てると、選択ドットだけが輪から外れて左にずれる問題を修正します。

Closes #18

原因と修正方針

輪(::before)は flex フロー配置なので padding に押されて動くのに対し、ドット(::after)は position: absolute; left: calc(...) の固定座標で、基準が padding を含まないため取り残されていました。

::after を廃止し、輪(::before)自身の background に radial-gradient でドットを描く方式に変更します。ドットは常に輪の中心に描画されるため padding に影響されません。DOM 構造の変更はなく CSS のみです。

選択時のアニメーションは transform: scale(0→1) の代わりに background-size: 0→サイズ(アニメーション可能プロパティ)で、従来と同等の「中心から広がる」動きを維持しています。

Before / After

状態 Before After
label に padding: 12px 16px 選択ドットが輪の左外にずれる ドットが輪の中心に描かれる
padding なし(通常) 従来どおり 変化なし

確認(Storybook)

  • padding 注入時: ドットが輪の中心に描画されること
  • 通常時: 選択切り替え・「中心から広がる」アニメーション・disabled 表示が従来どおり
  • キーボード操作: 矢印キーでの選択移動と data-focus-visible のフォーカスリング(::before の outline)が機能すること
  • npm run lint / npm run build … PASS

関連

ドットを ::after の絶対配置(left: calc(...) 固定)で重ねる方式から、
輪(:before)自身の background に radial-gradient で描く方式に変更する。
絶対配置の基準が padding を含まないため、label に padding を当てると
輪だけが動いてドットが取り残されていた。

選択時のアニメーションは transform: scale の代わりに background-size
(アニメーション可能)で中心から広がる動きを維持する。

Closes pepabo#18

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 3, 2026 10:05
@ryoshin0830 ryoshin0830 requested a review from nacal as a code owner July 3, 2026 10:05

Copilot AI 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.

Pull request overview

Radio コンポーネントで、ルート(label)に padding を付けた際に「選択ドット(内側の●)だけが輪(◯)からずれてしまう」問題を、DOM 構造を変えずに CSS のみで解消するPRです。

Changes:

  • 選択ドットの描画を ::after の絶対配置オーバーレイから、::before(輪)自身の background-image(radial-gradient)による描画へ変更
  • 選択アニメーションを transform: scale から background-size のトランジションに置き換え

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Radio の選択ドットが label の padding で位置ずれする

2 participants