selvagsz / react-power-select

A highly composable & reusable select/autocomplete components

Home Page:https://selvagsz.github.io/react-power-select/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Cannot read property 'focus' of null

c-emil opened this issue · comments

Hi, there's a problem with calling focus on element that doesn't exists anymore.

The Uncaught TypeError is triggered on this line: https://github.com/selvagsz/react-power-select/blob/master/src/Select.js#L156

The source of the problem is that powerselect element no longer exist but it tries to call the focus method on it. I think the setTimeout should be assigned to an instance variable and once the Select component is about to be destroyed, this timeout should be cleared out.

Or it can just check whether the element exists and only then call the focus on it. Let me know which option (if any) suits you better and I can submit PR for it.

commented

@c-emil we should be clearing the timeout on destroy

Alright, I'll submit a PR for that once I get to it.