angular-strap icon indicating copy to clipboard operation
angular-strap copied to clipboard

quickly filling in a typeahead box gets Cannot read property 'selectMode' of null

Open DealerCorp opened this issue 12 years ago • 17 comments

if type in everything slowly, it works fine. ng-options="ymm.Detail as ymm.Detail for ymm in getVehicles($viewValue)"

TypeError: Cannot read property 'selectMode' of null at https://mgcrea.github.io/angular-strap/dist/angular-strap.js:4293:23 at wrappedCallback (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:11572:81) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:11658:26 at Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:12701:28) at Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:12513:31) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:12739:26 at completeOutstandingRequest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:4397:10) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js:4705:7

DealerCorp avatar Oct 03 '14 15:10 DealerCorp

Can you provide a sample reproducing your issue please?

vmlf01 avatar Oct 22 '14 21:10 vmlf01

I'm getting the same, was this ever solved? TypeError: Cannot read property 'selectMode' of null at typeahead.js:259 at angular.js:13171 at l.$get.l.$eval (angular.js:14384) at l.$get.l.$digest (angular.js:14200) at l.$get.l.$apply (angular.js:14489) at l (angular.js:9646) at O (angular.js:9836) at XMLHttpRequest.w.onload (angular.js:9777)

Chise-Derrick avatar Feb 03 '15 21:02 Chise-Derrick

Getting the same issue.

tritonresearch avatar Mar 28 '15 22:03 tritonresearch

same issue

Hrafnkellos avatar May 21 '15 13:05 Hrafnkellos

can you change :

options.selectMode

to

options && options.selectMode

that will break the logic operator if null before it gets to options.selectMode

Hrafnkellos avatar May 21 '15 13:05 Hrafnkellos

@Hrafnkellos, not quite sure where you're making this edit. I tried a few places and it doesn't correct the issue.

Did you find a better solution?

Kegley avatar May 24 '15 01:05 Kegley

@Josh1289op Have you found a solution? I'm having this issue as well.

axschech avatar Aug 17 '15 19:08 axschech

As you can see in the stack trace the error is coming from a digest triggered by an xhr request completing. In my case after selecting an optiion the xhr was triggering to load items matching the text of what I selected (IMO it should not trigger a search after selecting item, seems pointless). I was redirecting ($location.path) in response to the selection and i would guess the xhr was completing after the typeahead directive had been destroyed.. maybe?

I think the fix is to simply not search after selecting - how is that useful?

PS. I stopped the error by setting a flag in the select event handler that stopped the search method from actually doing anything.

    var preventSearch  = false;
      $scope.search = function (query) {
        if (preventSearch) {
          return;
        }
    ....
    }

$scope.$on('$typeahead.select', function (event, value) {
        preventSearch = true;
        $location.path('...')
      });

worldspawn avatar Nov 23 '15 02:11 worldspawn

+1 this is still causing us issues as well.

robpolak avatar Jun 24 '16 17:06 robpolak

+1 same issue.

jfetter avatar Jun 24 '16 17:06 jfetter

This has been open for over two years, is this going to be addressed?

robpolak avatar Nov 11 '16 19:11 robpolak

We need a reproducible error for this. @robpolak have you tried to fix the bug?

DaleWebb avatar Nov 12 '16 15:11 DaleWebb

Guys, I believe Hrafnkellos solution solved this for me.

Chise-Derrick avatar Nov 13 '16 07:11 Chise-Derrick

Feel free to PR, @rexthepenguin, if you can get a test in-place too

DaleWebb avatar Nov 13 '16 22:11 DaleWebb

Sorry, it's been so long since I used it, I don't know where my code is, but I remember I search strap source for options.selectMode

and just changed it to:

options && options.selectMode

which makes sense as it checks that options isn't Null before it tries a method on it. Hope this helps

On 13 Nov 2016 22:07, "Dale Alexander Webb" [email protected] wrote:

Feel free to PR, @rexthepenguin https://github.com/rexthepenguin, if you can get a test in-place too

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mgcrea/angular-strap/issues/1124#issuecomment-260216516, or mute the thread https://github.com/notifications/unsubscribe-auth/AEEk_QikWU-iQd9NNAs4KLqfzHVzd-dqks5q94ougaJpZM4Cqhv0 .

Chise-Derrick avatar Nov 13 '16 22:11 Chise-Derrick

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 25 '19 22:01 stale[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar May 06 '19 22:05 lock[bot]