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

Cannot read properties of null (reading 'toLowerCase') #98

Open
stephanbruijnis opened this issue Feb 29, 2024 · 0 comments
Open

Cannot read properties of null (reading 'toLowerCase') #98

stephanbruijnis opened this issue Feb 29, 2024 · 0 comments

Comments

@stephanbruijnis
Copy link

There is an issue with the widget when sometimes it cannot process the following code:

                                if( attributeValue.toLowerCase().lastIndexOf(self._currentSearchTerm.toLowerCase(), 0) === 0 ){
                                filteredObjs.push(self._localObjectCache[i]);

It will show an error in the browser console:

mxui.js?638440481067909697:64 [Client] TypeError: Cannot read properties of null (reading 'toLowerCase')
    at request (widgets.js?638440481067909697:8080:48)

Issue also discussed here: https://community.mendix.com/link/space/widgets/questions/93784

a fix would be to wrap the following code in an if check if(attributeValue !== null)

                        if(self.cacheSearchMethod == "startswith"){
                            // startsWith not supported in IE
                            //if( attributeValue.toLowerCase().startsWith(self._currentSearchTerm.toLowerCase()) ){
                            if( attributeValue.toLowerCase().lastIndexOf(self._currentSearchTerm.toLowerCase(), 0) === 0 ){
                                filteredObjs.push(self._localObjectCache[i]);
                            }
                        }
                        else{
                            if( attributeValue.toLowerCase().indexOf(self._currentSearchTerm.toLowerCase()) >= 0 ){
                                filteredObjs.push(self._localObjectCache[i]);
                            }
                        }
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

No branches or pull requests

1 participant