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

Commit b1fefd8

Browse files
committed
Fix issue with the sizing of the text input field when the visibility of the input control is dynamically toggled, for example via the ng-disabled attribute on the <ui-select> element.
The problem is caused by the width calculation getting an incorrect 0 `offsetLeft` value for the input, as the `offsetParent` of the input is still `null` when the controller tries to calculate the width. The fix resolves this by adding a watch for the `offsetParent`, and only performing the width calculation when both the `offsetParent` *and* the container width are available.
1 parent da159d4 commit b1fefd8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/uiSelectController.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,12 @@ uis.controller('uiSelectCtrl',
377377
_searchInput.css('width',newWidth+'px');
378378
};
379379
$timeout(function(){ //Give tags time to render correctly
380-
if (container.clientWidth === 0 && !containerSizeWatch){
381-
containerSizeWatch = $scope.$watch(function(){ return container.clientWidth;}, function(newValue){
382-
if (newValue !== 0){
380+
if ((container.clientWidth === 0 || input.offsetParent === null) && !containerSizeWatch) {
381+
containerSizeWatch = $scope.$watchGroup([
382+
function(){ return container.clientWidth; },
383+
function(){ return input.offsetParent; }
384+
], function(newValues){
385+
if (newValues[0] !== 0 && newValues[1] !== null){
383386
calculate();
384387
containerSizeWatch();
385388
containerSizeWatch = null;

0 commit comments

Comments
 (0)