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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

huyph
Copy link

@huyph huyph commented Apr 6, 2023

Reasons for making this change

[Please describe them here]
When using the default SelectWidget from @rjsf/semantic-ui@5.5.0, I observed these errors from SelectWidget.tsx

Cannot read properties of undefined (reading 'value')
TypeError: Cannot read properties of undefined (reading 'value')
    at Object._onBlur [as **onBlur**] ...
...
Cannot read properties of undefined (reading 'value')
TypeError: Cannot read properties of undefined (reading 'value')
    at Object._onBlur [as **onFocus**] ...
...

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@huyph huyph changed the title Be more defensive in SelectWidget's onBlur and onFocus Handle undefined target in SelectWidget's onBlur and onFocus handlers Apr 6, 2023
@huyph huyph changed the title Handle undefined target in SelectWidget's onBlur and onFocus handlers Handle undefined target in SelectWidget's onBlur and onFocus Apr 6, 2023
Comment on lines +84 to +86
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
const _onFocus = (_: FocusEvent<HTMLElement>, { target }: DropdownProps) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
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.

@heath-freenome
Copy link
Member

heath-freenome commented Apr 27, 2023

@huyph I wondering when you'll get a chance to address my questions. Also you'll have to resolve conflicts now.

@huyph huyph closed this Jun 14, 2023
@hfjohn123
Copy link

Hi I am still having this problem with the newest version when I am utilizing semantic UI Theme. Is there any workaround?

@heath-freenome
Copy link
Member

@hfjohn123 I'm not sure why @huyph closed this PR. If you want to pick up this fix and address the additional potential changes I encourage you to do so and open your own PR.

@huyph huyph reopened this Jul 20, 2023
@huyph
Copy link
Author

huyph commented Jul 20, 2023

Hi @heath-freenome, I accidentally closed this PR. Sorry for the confusion.

I will try to get back to it within the next few weeks. Feel free to collaborate with me on this PR @hfjohn123

@ahmedsakri
Copy link

ahmedsakri commented Aug 16, 2023

Hi @heath-freenome , any update on this P.R? as i am too facing this issue. Thanks!

@heath-freenome
Copy link
Member

@ahmedsakri Maybe you'll need to collaborate with @huyph to get this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants