agroptima-design-system 0.25.3 → 0.25.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "0.25.3",
3
+ "version": "0.25.5",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -79,6 +79,7 @@ export function Multiselect({
79
79
  function handleClear(event: React.MouseEvent<HTMLButtonElement>) {
80
80
  event.stopPropagation()
81
81
  setSelectedOptions([])
82
+ if (onChange !== undefined) onChange([])
82
83
  }
83
84
 
84
85
  return (
@@ -78,6 +78,7 @@ export function Select({
78
78
  function handleClear(event: React.MouseEvent<HTMLButtonElement>) {
79
79
  event.stopPropagation()
80
80
  setSelectedOption(EMPTY_OPTION)
81
+ if (onChange !== undefined) onChange('')
81
82
  }
82
83
 
83
84
  return (
@@ -4,6 +4,11 @@ import { Meta } from "@storybook/blocks";
4
4
 
5
5
  # Changelog
6
6
 
7
+ # 0.25.5
8
+
9
+ * Call onChange after clearing Select and Multiselect components
10
+
11
+
7
12
  # 0.25.3
8
13
 
9
14
  * Add clear button to Select commponent
@@ -113,6 +113,7 @@ describe('Multiselect', () => {
113
113
  expect(getByText(/error2/i)).toBeInTheDocument()
114
114
  })
115
115
  it('clears options selected', async () => {
116
+ const mockChange = jest.fn()
116
117
  const user = userEvent.setup()
117
118
  const placeholder = 'Select your favourite videogames...'
118
119
  const { getByText } = render(
@@ -137,6 +138,7 @@ describe('Multiselect', () => {
137
138
  placeholder={placeholder}
138
139
  defaultValue={['2', '1']}
139
140
  selectedLabel="videogames selected"
141
+ onChange={mockChange}
140
142
  variant="primary"
141
143
  />,
142
144
  )
@@ -144,5 +146,6 @@ describe('Multiselect', () => {
144
146
  await user.click(screen.getByRole('button', { name: /close/i }))
145
147
 
146
148
  expect(getByText(placeholder)).toBeInTheDocument()
149
+ expect(mockChange).toHaveBeenCalledWith([])
147
150
  })
148
151
  })
@@ -119,6 +119,7 @@ describe('Select', () => {
119
119
  expect(getByText(/error2/i)).toBeInTheDocument()
120
120
  })
121
121
  it('clears option selected', async () => {
122
+ const mockChange = jest.fn()
122
123
  const user = userEvent.setup()
123
124
  const placeholder = 'Select your favourite gaming system...'
124
125
  const { getByText } = render(
@@ -143,6 +144,7 @@ describe('Select', () => {
143
144
  },
144
145
  ]}
145
146
  placeholder={placeholder}
147
+ onChange={mockChange}
146
148
  variant="primary"
147
149
  />,
148
150
  )
@@ -150,5 +152,6 @@ describe('Select', () => {
150
152
  await user.click(screen.getByRole('button', { name: /close/i }))
151
153
 
152
154
  expect(getByText(placeholder)).toBeInTheDocument()
155
+ expect(mockChange).toHaveBeenCalledWith('')
153
156
  })
154
157
  })