Babylon.gui.min.js: Uncaught TypeError: Cannot read property 'isFocusInvisible' of undefined

Hi there,
i don’t understand how to catch this error: it seems to happen when i set focus on an input text block, but i did’t understand why.
In babylon.gui.min.js this is the snippet of code in which the error occours:

            e.prototype._manageFocus = function() {
                if (this._blockNextFocusCheck)
                    return this._blockNextFocusCheck = !1,
                    void (this._lastPickedControl = this._focusedControl);
                if (this._focusedControl && this._focusedControl !== this._lastPickedControl) {
                    **if (this._lastPickedControl.isFocusInvisible)**
                        return;
                    this.focusedControl = null
                }
            }

It seems that this._lastPickedControl is “undefined”.
Any idea how to prevent this?

pinging @msDestiny14

Can you reproduce this on the playground?

I’ll try, but at the moment i can reproduce it only in my application.

HI @RaananW , i can repro on this PG: Babylon.js Playground !! :slight_smile:
The class MagGUI is quite similar to my application.
All work fine but if you look in the console you will find that error.
Where do i mistake?

EDIT: i think the error is connected to the method ShowSearchInput (line 189).
EDIT2: if i comment line 60 all work fine

you could use moveFocusToControl instead: https://playground.babylonjs.com/#1Y5YAM#1

@msDestiny14 should still verify if the _lastPickedControl is null before the code you mentionned.

1 Like

Thank you @sebavan, you saved me hours of work!!! I owe you a beer :slight_smile: