Skip to content

Commit

Permalink
fix(select): Issue #60 - Use suffixIcon instead of deprecated showArrow
Browse files Browse the repository at this point in the history
BREAKING CHANGE: antd >= v5.8.0 required
  • Loading branch information
xrutayisire committed Oct 8, 2023
1 parent 1521675 commit a766b5b
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 198 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ react-js-cron is written in TypeScript with complete definitions
Be sure that you have these dependencies on your project:

- react (>=17.0.0)
- antd (>=5.5.0)
- antd (>=5.8.0)

```bash
# NPM
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"enhanced-resolve": "5.10.0"
},
"peerDependencies": {
"antd": ">=5.5.0",
"antd": ">=5.8.0",
"react": ">=17.0.0",
"react-dom": ">=17.0.0"
},
Expand Down Expand Up @@ -93,7 +93,7 @@
"@types/react-dom": "18.0.9",
"@typescript-eslint/eslint-plugin": "5.44.0",
"@typescript-eslint/parser": "5.44.0",
"antd": "5.6.1",
"antd": "5.9.4",
"babel-loader": "8.3.0",
"cz-conventional-changelog": "3.3.0",
"del-cli": "5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export default function CustomSelect(props: CustomSelectProps) {
popupClassName={popupClassName}
options={options}
showSearch={false}
showArrow={!readOnly}
suffixIcon={readOnly ? null : undefined}
menuItemSelectedIcon={null}
popupMatchSelectWidth={false}
onSelect={onOptionClick}
Expand Down
2 changes: 1 addition & 1 deletion src/fields/Period.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function Period(props: PeriodProps) {
className={selectClassName}
popupClassName={popupClassName}
disabled={disabled}
showArrow={!readOnly}
suffixIcon={readOnly ? null : undefined}
open={readOnly ? false : undefined}
data-testid='select-period'
allowClear={allowClear}
Expand Down
38 changes: 38 additions & 0 deletions src/tests/Cron.updateValue.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,42 @@ describe('Cron update value test suite', () => {
expect(onError).toHaveBeenNthCalledWith(3, undefined)
})
})

it("should check that it's not possible to update value when it's readOnly mode", async () => {
const user = userEvent.setup()
const value = '1,4 * * * *'
const setValue = jest.fn()

render(<Cron value={value} setValue={setValue} readOnly />)

// Open minute dropdown
await waitFor(() => user.click(screen.getByText('1,4')))

// Check dropdown is not visible
await waitFor(() => {
expect(screen.queryByText('59')).not.toBeInTheDocument()
})

// Check dropdowns values still the sane
expect(await screen.findByText('1,4')).toBeVisible()
})

it("should check that it's not possible to update value when it's disabled mode", async () => {
const user = userEvent.setup()
const value = '1,4 * * * *'
const setValue = jest.fn()

render(<Cron value={value} setValue={setValue} disabled />)

// Open minute dropdown
await waitFor(() => user.click(screen.getByText('1,4')))

// Check dropdown is not visible
await waitFor(() => {
expect(screen.queryByText('59')).not.toBeInTheDocument()
})

// Check dropdowns values still the sane
expect(await screen.findByText('1,4')).toBeVisible()
})
})
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export interface CustomSelectProps
| 'tagRender'
| 'dropdownRender'
| 'showSearch'
| 'showArrow'
| 'suffixIcon'
| 'onChange'
| 'dropdownMatchSelectWidth'
| 'options'
Expand Down
Loading

0 comments on commit a766b5b

Please sign in to comment.