diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f2fd0c7eaea..cb348caeb12a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ - CLI: Fix race condition in sb init [#19083](https://github.com/storybooks/storybook/pull/19083) - Vite: Fix framework option checks, and SSv6 [#19062](https://github.com/storybooks/storybook/pull/19062) - Core: Fix WebProjectAnnotations export in preview-web for back-compat [#19048](https://github.com/storybooks/storybook/pull/19048) +- Blocks: Fix Checkbox control update when using useArgs hook #### Maintenance diff --git a/code/lib/blocks/src/controls/options/Checkbox.tsx b/code/lib/blocks/src/controls/options/Checkbox.tsx index 0e2afe03c1a7..3f75d63db2e2 100644 --- a/code/lib/blocks/src/controls/options/Checkbox.tsx +++ b/code/lib/blocks/src/controls/options/Checkbox.tsx @@ -1,4 +1,4 @@ -import React, { FC, ChangeEvent, useState } from 'react'; +import React, { FC, ChangeEvent, useState, useEffect } from 'react'; import { styled } from '@storybook/theming'; import { logger } from '@storybook/client-logger'; import { ControlProps, OptionsMultiSelection, NormalizedOptionsConfig } from '../types'; @@ -70,6 +70,10 @@ export const CheckboxControl: FC = ({ setSelected(updated); }; + useEffect(() => { + setSelected(selectedKeys(value, options)); + }, [value]); + const controlId = getControlId(name); return (