Skip to content

Commit

Permalink
Fix isDisabled in RadioCard and ChoiceChip (#1418)
Browse files Browse the repository at this point in the history
* Wrap data attributes in dataAttr() util

* Fix data-disabled for ChoiceChip

* Fix disabled input state in ChoiceChip

* Add changeset
  • Loading branch information
matsaaj authored Dec 13, 2024
1 parent f341b2e commit e2d26fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-apples-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vygruppen/spor-react": patch
---

Fix isDisabled for RadioCard and ChoiceChip
4 changes: 2 additions & 2 deletions packages/spor-react/src/input/ChoiceChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const ChoiceChip = forwardRef(
<chakra.input
{...getInputProps({}, ref)}
id={id}
disabled={isDisabled}
disabled={isDisabled || state.isDisabled}
/>
<chakra.div
{...getLabelProps()}
Expand All @@ -102,7 +102,7 @@ export const ChoiceChip = forwardRef(
data-hover={dataAttr(state.isHovered)}
data-focus={dataAttr(state.isFocused)}
data-active={dataAttr(state.isActive)}
data-disabled={dataAttr(state.isDisabled)}
data-disabled={dataAttr(isDisabled || state.isDisabled)}
>
{icon && (
<chakra.span __css={styles.icon}>
Expand Down
7 changes: 4 additions & 3 deletions packages/spor-react/src/layout/RadioCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "@chakra-ui/react";
import React, { useContext, useEffect, useId, useState } from "react";
import { RadioCardGroupContext } from "./RadioCardGroup";
import { dataAttr } from "@chakra-ui/utils";

/**
* Radio cards are used to present a set of options where only one option can be selected.
Expand Down Expand Up @@ -107,9 +108,9 @@ export const RadioCard = forwardRef(
as="label"
name={name}
htmlFor={inputId}
aria-checked={isChecked}
data-checked={isChecked}
data-disabled={isDisabled}
aria-checked={dataAttr(isChecked)}
data-checked={dataAttr(isChecked)}
data-disabled={dataAttr(isDisabled)}
{...props}
__css={{
...styles.container,
Expand Down

0 comments on commit e2d26fd

Please sign in to comment.