Skip to content

Commit

Permalink
fix(checkbox-input): display checkmark when checked is true (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstaley committed Aug 17, 2022
1 parent ccc37c5 commit 3714aff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-parrots-compete.md
@@ -0,0 +1,5 @@
---
'@hashicorp/react-checkbox-input': patch
---

Display checkmark when checked is true
2 changes: 1 addition & 1 deletion packages/checkbox-input/index.js
Expand Up @@ -35,7 +35,7 @@ function CheckboxInput({
>
<div className={s.wrapper}>
<span className={s.checkbox}>
{field.value && <SvgrCheckmark />}
{field.value || field.checked ? <SvgrCheckmark /> : null}
<input id={inputId} type="checkbox" {...field} />
</span>

Expand Down
15 changes: 13 additions & 2 deletions packages/checkbox-input/index.test.js
Expand Up @@ -37,12 +37,23 @@ describe('<CheckboxInput />', () => {
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(
<CheckboxInput
{...defaultProps}
field={{ ...props.field, value: true, checked: true }}
field={{ ...props.field, value: true }}
/>
)
expect(container.querySelector('svg')).toBeInTheDocument()
})

it('should show the Check icon when the input is checked via checked', () => {
const props = defaultProps
const { container } = render(
<CheckboxInput
{...defaultProps}
field={{ ...props.field, checked: true }}
/>
)
expect(container.querySelector('svg')).toBeInTheDocument()
Expand Down

1 comment on commit 3714aff

@vercel
Copy link

@vercel vercel bot commented on 3714aff Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

You don't have permission to create a Production Deployment for this project.

View Documentation: https://vercel.com/docs/concepts/teams/roles-and-permissions

Please sign in to comment.