Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

minimum-input-length with refresh-delay causes problems #1898

Open
ghost opened this issue Jan 27, 2017 · 4 comments
Open

minimum-input-length with refresh-delay causes problems #1898

ghost opened this issue Jan 27, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 27, 2017

There is a bug using refresh-delay and minimum-input-length in combination.
I've created a plunker http://plnkr.co/edit/D1NQYP8qBfQuUskak7Ei

I expect the refresh function should not be called with search strings shorter minimum-input-length

@Jefiozie
Copy link
Contributor

Hi,
had a look at your issue but I cannot really reproduce the issue you are (i believe) described. So i filled a couple of random characters in (more than 5) and the refresh function worked. Deleted everything, no refresh, added 1 char no refresh. Until I had entered 5 characters. Could you explain what I'm doing wrong?

@ghost
Copy link
Author

ghost commented Jan 31, 2017

Fill in 6+ characters then press & hold backspace. Don't delete them all at once.
image

@Jefiozie
Copy link
Contributor

Jefiozie commented Feb 1, 2017

So i think i have found the problem you are describing. Basicly the problem comes from this line Line 65

The $select.search value will be the old value and not the newValue. I think this should be the length of the newValue that needs to be compared to the minimumlength. Do you agree on this?

Made a example plunker with this fix. Example fix

@ghost
Copy link
Author

ghost commented Feb 6, 2017

Thank you for your support but the problem is still existent in your example.
I think its caused in Line 300 of uiSelectController.
The inputLenght should be checked in the moment the timeout is executed.
Imho the delayed execution of the $scope.$eval(refreshAttr) needs to be skipped if $select.search.length < minimum-input-length.
Something like this should work.

var refreshPromise = $scope.$select.search.length >= minimum-input-length ? $scope.$eval(refreshAttr) : false;

I would do a PR but i cant figure out how to access minimum-input-length in the uiSelectController.
I hope everything was understandable for you.

Jefiozie added a commit that referenced this issue Apr 4, 2017
fix minimum-input-length with refresh-delay #1898
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant