-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(#271) if option is set the refresh function is getting the request. #1845
Conversation
…ction is getting the request.
Could we instead pass |
Instead of the refreshIsActive ? Will run some tests with it. DId some test changing the isActive to open will have the same behaviour. |
Ah we actually have two "issues" here:
For 2 we don't need a new attribute, just call |
But if we look if |
Did some test to verify if this solution is working.....and it will break a lot of tests. Need to dig a little bit deeper because in the test the function |
@Jefiozie I think you misunderstand, we do not need to do anything with
I cannot test this right now but I think it should be correct? The only thing extra we need to do it, is call Does that make sense? |
Tagging #1174 for reference. |
@user378230 , understand you now and agree on both points. Will remove the extra parameters/ variables and add the |
@user378230 , Next problem: Keep you posted |
@@ -55,10 +55,9 @@ uis.directive('uiSelectChoices', | |||
|
|||
|
|||
$select.parseRepeatAttr(attrs.repeat, groupByExp, groupFilterExp); //Result ready at $select.parserResult | |||
|
|||
$select.refreshOnActive = scope.$eval(attrs.refreshOnActive); |
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.
Lets remove the attribute, this can be default functionality. We just call refresh more often now. (ie. When search.length == 0
)
@@ -68,7 +67,7 @@ uis.directive('uiSelectChoices', | |||
scope.$watch('$select.search', function(newValue) { | |||
if(newValue && !$select.open && $select.multiple) $select.activate(false, true); | |||
$select.activeIndex = $select.tagging.isActivated ? -1 : 0; | |||
if (!attrs.minimumInputLength || $select.search.length >= attrs.minimumInputLength) { | |||
if ((!attrs.minimumInputLength || $select.search.length >= attrs.minimumInputLength) && (!$select.refreshOnActive || ($select.refreshOnActive && $select.open))) { |
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.
We can undo changes here also. It will be up to user to check in their own function.
scope.$watch('$select.open', function(open) { | ||
if (open) { | ||
tElement.attr('role', 'listbox'); | ||
if(!angular.isUndefined($select.refreshOnActive)){ |
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 wonder instead if we do this in a uis:activate
listener? (So it's clearer)
@user378230 I removed this already only I didn't commit it. Can commit the latest changes if you want? |
Commit what you have I can always pull down and test myself 😁 |
Here it is 😈 |
@@ -68,7 +66,7 @@ uis.directive('uiSelectChoices', | |||
scope.$watch('$select.search', function(newValue) { | |||
if(newValue && !$select.open && $select.multiple) $select.activate(false, true); | |||
$select.activeIndex = $select.tagging.isActivated ? -1 : 0; | |||
if (!attrs.minimumInputLength || $select.search.length >= attrs.minimumInputLength) { | |||
if ((!attrs.minimumInputLength || $select.search.length >= attrs.minimumInputLength) && $select.open) { |
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.
How come you changed this? I didn't think it would be needed? Does reverting this fix tests?
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 changed this as this will prevent the initial request of the refresh function on initializing.
Yes reverting will fix the tests.
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.
So we can revert this then. 😁
From my comment a few days ago:
the user can check manually in fetchFromServer(...) if select is open
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.
Based on your comment yes we can revert. But still on initializing the refresh will be exectued. And this is not the behavior as it should be i think and also the problem of #271 ?
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.
As I said before I want the user to check if it's open not us, users should already be able to do this. (I'm writing on mobile so my replies are short sorry!).
I also don't want to add breaking change as some users might like to load on initialise.
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.
Okay, if that is the case then we can revert almost everything. Only thing we need to add is when activating/focus
the control we need to execute the refresh
function.
The users can already check if it is open by adding (as you already mentioned) a second param $select.open
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.
Yup 😁 if I could add functionality while reducing lines of code I would! 😛 Hopefully we both learned something more about ui-select though 😂
@@ -257,8 +254,6 @@ uis.controller('uiSelectCtrl', | |||
if (ctrl.dropdownPosition === 'auto' || ctrl.dropdownPosition === 'up'){ | |||
$scope.calculateDropdownPos(); | |||
} | |||
|
|||
$scope.$broadcast('uis:refresh'); |
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.
Why was the removed?
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.
Because nothing is listing on it.
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.
Can't users listen on it? 🤔 I don't use events much in angular so not completely sure!
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.
Yes you could both I cannot think of any use case where you need this? And if we want to support this it should be in the refresh
function instead of activate
.
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.
No harm is keeping it there now, someone might use it already and we should avoid breaking their use case 😬
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.
agree, but still it doesn't feel good to leave code that does nothing.
@user378230, so reverted the broadcast event. But also found a other use case where we could fix the original problem.By checking if the Second we will fire a refresh on activating the ui-select where the value of Do you believe this is a good way to solve the problem? p.s. all test are passing. 😄 |
Isn't this the use case I said we wanted to keep? (Calling the refresh function when the directive is first loaded?) Or am I misunderstanding what you said... After this PR we should have 3 different routes to calling refresh:
You are making me work hard for this PR haha! 😆 |
@user378230 , thanks for all the feedback great PR 😆!
With some tests of course. |
@Jefiozie Think you just need to review your commit once more (can you revert empty line changes too and an extra whitespace) And tests are like gold dust in library, so the more the better! 👍 |
@user378230, so after this intensive PR 😈 i think we have learned and made it a little beter. Right 😉 , again thanks for the feedback/ help and good discussion. |
@Jefiozie check the files tab on here please... 🙂 |
This reverts commit d7a5df2.
@user378230 ,Think it looks better now. |
Queued for next released. Just want to undo the unnecessary empty line changes before I merge. |
@user378230 , Any ideas when this will be merged? |
@Jefiozie Can you resolve the conflicts so that I can merge? Thanks for all your work! |
Sure will have a look. Does @user378230 not maintain this repository any more or is he gone (as far as you know)? |
@aaronroberson , see my previous comment. Does @user378230 not maintain this repository any more or is he gone (as far as you know)? |
@aaronroberson , made the changes. I can be merged also can you reply on previous comments? |
@aaronroberson sorry to bother you but I'm seeing the issue list grow and want to help getting this a little bit smaller. Can you merge this? Thanks. |
@aaronroberson @user378230 sorry to bother you guys. But this libary needs some attention. CC @wesleycho , maybe you can contact people above? (thanks and sorry to bother you just wanne keep te libary "up to date") |
Can you send me an email to discuss having you help maintain the project? My email is aaronaroberson at gmail. |
fix(angular-ui#271) if option is set the refresh function is getting the request.
when ui-select is multiple , function refresh can't get $select . |
I think this is something that is requested multiple times: #271, #625,#619.
Used the initial changes from 625 with some minor adjustments to let everything work and only watch variables if needed.
If this is a viable solution i think all the other can be closed down.