diff --git a/.changeset/early-parrots-compete.md b/.changeset/early-parrots-compete.md new file mode 100644 index 000000000..8b6cf5b31 --- /dev/null +++ b/.changeset/early-parrots-compete.md @@ -0,0 +1,5 @@ +--- +'@hashicorp/react-checkbox-input': patch +--- + +Display checkmark when checked is true diff --git a/packages/checkbox-input/index.js b/packages/checkbox-input/index.js index 57daf0627..c41440c8c 100644 --- a/packages/checkbox-input/index.js +++ b/packages/checkbox-input/index.js @@ -35,7 +35,7 @@ function CheckboxInput({ >
- {field.value && } + {field.value || field.checked ? : null} diff --git a/packages/checkbox-input/index.test.js b/packages/checkbox-input/index.test.js index c2ae6ae2b..3782685ab 100644 --- a/packages/checkbox-input/index.test.js +++ b/packages/checkbox-input/index.test.js @@ -37,12 +37,23 @@ describe('', () => { expect(screen.getByText(emText).tagName).toBe('EM') }) - it('should show the Check icon when the input is checked', () => { + it('should show the Check icon when the input is checked via value', () => { const props = defaultProps const { container } = render( + ) + expect(container.querySelector('svg')).toBeInTheDocument() + }) + + it('should show the Check icon when the input is checked via checked', () => { + const props = defaultProps + const { container } = render( + ) expect(container.querySelector('svg')).toBeInTheDocument()