Skip to content

🐛 asChild で無効化したとき、Button / IconButton の無効時の配色が適用されない #311

Description

@touyou

事象

Button / IconButton の無効状態のスタイルは disabled: プレフィックスで出力されているため、asChild<a>Link を差し込んだ場合に一切適用されません:disabled 疑似クラスは form control にしかマッチしないため)。

<IconButton asChild icon="edit" aria-label="編集" isDisabled>
  <a href="/foo" />
</IconButton>

つまり「操作はできないが、見た目は無効に見えない(むしろ配色が抜けている)」という状態になります。

対応案

disabled: の compoundVariant に aria-disabled: 系のユーティリティを併記する。

-  "disabled:bg-surface-primary-high-disabled disabled:text-object-inverse"
+  "disabled:bg-surface-primary-high-disabled disabled:text-object-inverse"
+  + " aria-disabled:bg-surface-primary-high-disabled aria-disabled:text-object-inverse"

確認が必要な点:

  • sparkle-design-cli が生成する CSS と Tailwind 4 のスキャンで aria-disabled: バリアントが期待どおり出力されるか(今回この確認が要るため 🐛 fix: IconButton の asChild と native disabled の不具合を修正 #307 のスコープ外にしました)
  • Button / IconButton の両方を同時に対応すること
  • data-disabled を利用側スタイルフックとして残すか、aria-disabled: 対応後は不要とするか

出所

#307#304 / #305 対応)のレビューで検出。#307 では既知の制約として JSDoc のアクセシビリティ節と dev 警告で利用者に伝える形にしています。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions