-
Notifications
You must be signed in to change notification settings - Fork 540
Conversation
My bad about the three test commits -- I'm fairly new to git and I was using them to make sure I was pushing to my fork...I couldn't figure out how to revert them after I'd done it. |
Hi @FoxxMD. Thanks for contributing! 👍 Before I can merge your PR into the master branch I'd like to ask you to do some changes:
I'd also like to make a couple of comments about the code, but will do that directly in the changed files. After performing those changes, you'll need to force a push into your forked repo so the PR gets updated. Kind regards. |
if (query.length < options.minLength) { | ||
self.reset(); | ||
return; | ||
if(!options.openOnFocus) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the minLength
option should be ignored here. It has nothing to do with the openOnFocus
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring minLength
when the flag is set insures the the menu will not close when input is blank. Perhaps I'll change the condition to (query.length < options.minLength && !options.openOnFocus)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I get it now. But it still seems odd to me that one flag named showOnFocus
interferes with another one called minLength
. I mean, the way I see it, showOnFocus
should only ensure the load()
method is called upon the input getting focus, and nothing else. Perhaps there should be another option, say showOnEmpty
that would do precisely that: call load()
when the input is empty (which in the end would be the same as setting minLength
to 0).
And let's not forget about issue #54, which relates to this behavior as well. There's a lot to consider here. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed! Another thing to think about -- addOnBlur
is set to true by default. Because of this if you leave the input area you automatically get a tag made from the input. So really any time the input area gets focus
the input is blank. Using what I have done still makes sense because input length will (almost) always be zero. However it does make behavior a little more opaque... I may just try and tackle #54 and refactor this into its own function.
Thanks for the feedback! I will have everything cleaned up by tomorrow. |
I've added opening the dropdown on key down(and set up scrolling, etc.). However I am having trouble with getting my tests to work properly.. my code is as follows:
As far as I can tell the behavior of the new features work correctly (the first two assertions pass and I've stepped through in debugging to make sure everything is called correctly) but Any suggestions on what I can do to fix this? Also: Would you like "open on down arrow" to be a separate pull request? |
In order for Angular to render the directive's markup you need to call Finally, I like the idea of having this "open on down arrow" feature as a separate PR. |
I am calling The keydown event triggers I'm still new to karma/jasmine but I'm sure there must be a way to I will move the keydown feature into a seperate PR and also create a full suite for each feature. |
Sorry. I didn't notice you were calling In fact, I realize now that there's no need to use that function at all. All you have to do is simulate a down arrow keystroke and then assert that the it('calls the load function with an empty query when the down arrow key is pressed', function() {
// Act
sendKeyDown(KEYS.down)
$timeout.flush();
// Assert
expect($scope.loadItems).toHaveBeenCalledWith('');
}); There are other tests ensuring that the autocomplete list is correctly rendered, so no need to do that again here. :) |
Ah I see! I was thinking of the test as having to simulate the entire action but it just needs to "cover" what hasn't been tested, that makes things so much easier! Thanks for all the help btw. You've been very patient with me! |
I think I got everything covered! Let me know if there's anything else I need to do. thanks |
I guess some tweaking is still needed, but I'll do it myself. One last thing I'd like you to do is squash your commits into one, following the commit message guidelines (which I see you're already doing). Thanks again for contributing! |
Okay I'll fix the branch up tomorrow morning. What other tweaking needs to be done? |
Not much. I'm not sure if passing But there's no point in asking you to do everything. I'm supposed to work as well. :) |
Add an option to allow the tag list to show when input is empty. This feature is useful when the user wants to see an unfiltered list of all available suggestions before typing. The Source expression must be able to handle a null query if this option is used. Partially addresses mbenford#54
If it was
passing
Basically because of all of those things it's simpler to pass |
Hi @FoxxMD. Sorry for taking so long to reply your message. I'll take a closer look at your PR this week and come back to you as soon as I can. |
@mbenford is there any updates? I am adding auto-complete into my project and I want to use this feature |
@just-boris This PR is selected for the next release, v2.1.0. |
I've made some small tweaks to autocomplete to provide an "openOnFocus" option. When openOnFocus is true and the user triggers a focus event on the inputTags input element the autocomplete dropdown will open automatically.