Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle undefined target in SelectWidget's onBlur and onFocus #3585

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ should change the heading of the (upcoming) version to include a major version b

-->

# 5.5.3
## @rjsf/semantic-ui
- Updated `SelectWidget` to handle undefined `target` in `onFocus` and `onBlur` handlers

# 5.5.2

## @rjsf/material-ui
Expand Down Expand Up @@ -94,6 +98,7 @@ should change the heading of the (upcoming) version to include a major version b

- Converted the `playground` to use Typescript, including some refactoring of code to make that job easier
- Updated the `custom-templates` documentation to add `errorSchema` to the props for `ObjectFieldTemplate`

# 5.4.0

## @rjsf/antd
Expand Down Expand Up @@ -145,8 +150,6 @@ should change the heading of the (upcoming) version to include a major version b
- Updated `CheckboxWidget` to show the `description` using the `DescriptionFieldTemplate`, fixing [#2791](https://github.com/rjsf-team/react-jsonschema-form/issues/2791)

## @rjsf/semantic-ui

-
- Updated `ObjectFieldTemplate` to hide the titles and descriptions when `displayLabel` is true (including globally), fixing [#3231](https://github.com/rjsf-team/react-jsonschema-form/issues/3231)
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `SelectWidget` and `TextareaWidget` to hide labels when `hideLabel` is true using the new `labelValue()` helper (including globally)
- Updated `CheckboxWidget` to show the `description` using the `DescriptionFieldTemplate`, fixing [#2791](https://github.com/rjsf-team/react-jsonschema-form/issues/2791)
Expand Down
8 changes: 4 additions & 4 deletions packages/semantic-ui/src/SelectWidget/SelectWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
const _onChange = (_: SyntheticEvent<HTMLElement>, { value }: DropdownProps) =>
onChange(enumOptionsValueForIndex<S>(value as string[], enumOptions, optEmptyVal));
// eslint-disable-next-line no-shadow
const _onBlur = (_: FocusEvent<HTMLElement>, { target: { value } }: DropdownProps) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, optEmptyVal));
const _onFocus = (_: FocusEvent<HTMLElement>, { target: { value } }: DropdownProps) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, optEmptyVal));
const _onBlur = (_: FocusEvent<HTMLElement>, { target }: DropdownProps) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
const _onFocus = (_: FocusEvent<HTMLElement>, { target }: DropdownProps) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
Comment on lines +84 to +86
Copy link
Member

Choose a reason for hiding this comment

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

Is this the only component that has this issue? Maybe the same change needs to be made for all of the other widgets that deal with onBlur/onFocus?

Copy link
Author

Choose a reason for hiding this comment

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

I will look into it.

const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);

return (
Expand Down