Skip to content

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

@stephanbruijnis

Description

@stephanbruijnis

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]);
                            }
                        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions