mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 09:51:36 +00:00
fix(radio-tile): allow standalone RadioTile
usage (#2136)
Although `RadioTile` is meant to be used inside a `TileGroup`, it feels unpolished for standalone usage to crash due to a missing parent context. This fixes `RadioTile` to fail open by providing a no-op `add: () => {}` when `TileGroup` context is not found.
This commit is contained in:
parent
1462e300d6
commit
ca9beebaea
2 changed files with 2 additions and 2 deletions
|
@ -36,6 +36,7 @@
|
|||
const { add, update, selectedValue, groupName, groupRequired } = getContext(
|
||||
"TileGroup",
|
||||
) ?? {
|
||||
add: () => {},
|
||||
groupName: readable(undefined),
|
||||
groupRequired: readable(undefined),
|
||||
selectedValue: readable(checked ? value : undefined),
|
||||
|
|
|
@ -94,8 +94,7 @@ describe("RadioTile", () => {
|
|||
expect(radioTileLabel).toHaveAttribute("for", "custom-id");
|
||||
});
|
||||
|
||||
// TODO(bug): support standalone radio tile.
|
||||
it.skip("should handle custom name", () => {
|
||||
it("should handle custom name", () => {
|
||||
render(RadioTileSingle);
|
||||
|
||||
expect(screen.getByRole("radio")).toHaveAttribute("name", "custom-name");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue