-
Notifications
You must be signed in to change notification settings - Fork 531
fix #287 - checks itemNode is not null in maybeScrollItemIntoView #293
base: master
Are you sure you want to change the base?
Conversation
Same as #281 |
I'll close it as soon as the other pull request is merged : it's been needed for a long time, a little reminder for the admins/maintainers doesn't hurt. |
That's right 😄 |
What about merge this PR? I'm using 1.5.5 version of react-autocomplete with rendering menu to body (due to issues with /cc @CMTegner |
I am still having issues with this always being null, so quickly i monkey-patched this function, by using inheritance ( fast and dirty). checkout the component scroll-into-view, it's pretty sweet. I also don't show scrollbars in my app because they are king of unnecessary, this stops the outer window form bouncing.
|
As I've mentioned before, this is most likely due to a mismatch between what you are passing in as This is documented:
If you think that this is not the case I'd be happy to look over a reduced test case to confirm that there is in fact a different bug in play. |
I got this error (and several others) when I was trying to use a functional component in the Example (react 15.6.1): https://codesandbox.io/s/32lz0wmmm1 With react 16 there is additional warning:
|
When an async function is loading the data:
The itemNode is sometime null in this function : https://github.com/reactjs/react-autocomplete/blob/master/lib/Autocomplete.js#L245.
In the ref function of the renderMenu member function (https://github.com/reactjs/react-autocomplete/blob/master/lib/Autocomplete.js#L437), the
ref
parameter is null too and sets the refs[item-
+ index] to nullI tried to not set the key in the
ref
function if the value was null but it didn't help.So ultimately I decided to protect the call to scrollIntoView to avoid the exception.
I hope it can fix the problem until you find a better solution if there is one.
PS : sorry, i forgot to read the contribution rules before commiting. My commit is prefixed by
fix
though.