-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open on focus #428
Comments
I'd like help on this too. Currently, the behavior is different when you click into the form field vs. when you tab in. I'd expect them to behave the same. |
I'd like help on this too. please update here if you guys found the solution |
Just what I was looking for as well. I am looking into it and will report back with what I find. |
Any ideas? My issue is that the border or the select control gets focus when tabbed, but I'd rather the input get the focus. Any ideas? |
👍 |
I tried the options suggested here 👉 #201 but I was not able to get the open-on-focus behavior |
+1 absolutely agree with @NickChristensen, I also expect the behaviour to be the same. |
👍 |
2 similar comments
+1 |
+1 |
In 4 updates |
For anyone interested in a temporary work around. HTML:
Controller:
This may/may not work on older browsers, but works well enough for what I need. The takeaway here is that you simply add a 'focus-input-tab_index_here' class onto to the ui-select you wish to focus/click on. The span has the tab index of the next input. Once it gets focus, it runs the function to select the anchor tag inside the ui-select. Luckily, once it's click, the input inside the ui-select will get the actual focus and be fairly seamless. I tried using ui-select's 'focus-on' attribute in a similar way, but failed to get it just how I wanted it. |
Here's a // Use the ui-select-open-on-focus directive on the ui-select element
app.directive('uiSelectOpenOnFocus', ['$timeout', function($timeout){
return {
require: 'uiSelect',
restrict: 'A',
link: function($scope, el, attrs, uiSelect) {
var closing = false;
angular.element(uiSelect.focusser).on('focus', function() {
if(!closing) {
uiSelect.activate();
}
});
// Because ui-select immediately focuses the focusser after closing
// we need to not re-activate after closing
$scope.$on('uis:close', function() {
closing = true;
$timeout(function() { // I'm so sorry
closing = false;
});
});
}
};
}]); |
+1 ^ |
+1 |
up |
+1 |
4 similar comments
+1 |
+1 |
+1 |
👍 |
Please don't post any more +1s - use the new GitHub reactions. PRs welcome for implementing this. |
@rahatarmanahmed That directive works perfect, ... but not in IE (at least tested in 11 and Edge). edit
|
It looks like the code still may have a race condition possible where it gets in a bad state. If for any reason, the 'focus' event is handled before the 'uis:close' event, then this directive will not work. I made some modifications to the code that uses the 'uis:activate' event to also disable the autoopen. I also took some liberties with variable names since For those who are interested, we have implemented this functionality into the Form.io JSON form renderer found here https://github.com/formio/ngFormio
|
not sure about the latest version, but for old one this solution doesn't work for multi selection,
works for me. |
I am facing a similar issue #1827 |
+1 |
1 similar comment
+1 |
@Metrakit previously stated please do not +1 issues. |
Using the solution posted by @travist works in latest Chrome and Edge; however, I cannot tab out of the field in Firefox. |
Same here. Tabbing out of Firefox does not work. Chrome is fine. |
Hello,
I have a simple thing I want to do - when someone tabs over to my ui-select, I want it to drop down automatically. Unfortunately, the ng-focus doesn't seem to fire when the focus changes to the ui-select. Is there a workaround?
The text was updated successfully, but these errors were encountered: