Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit 1fccbc6

Browse files
authored
Don't size search input below min width when recalculating width (#7)
1 parent 7900b41 commit 1fccbc6

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

dist/select.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.19.6 - 2017-06-17T00:07:08.500Z
4+
* Version: 0.19.6 - 2017-06-19T20:41:18.630Z
55
* License: MIT
66
*/
77

dist/select.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.19.6 - 2017-06-17T00:07:08.282Z
4+
* Version: 0.19.6 - 2017-06-19T20:41:18.435Z
55
* License: MIT
66
*/
77

@@ -828,6 +828,7 @@ uis.controller('uiSelectCtrl',
828828

829829
var input = ctrl.searchInput[0],
830830
container = ctrl.searchInput.parent().parent()[0],
831+
minInputWidth = 50,
831832
calculateContainerWidth = function() {
832833
// Return the container width only if the search input is visible
833834
return container.clientWidth * !!input.offsetParent;
@@ -837,12 +838,14 @@ uis.controller('uiSelectCtrl',
837838
return false;
838839
}
839840
var inputWidth = containerWidth - input.offsetLeft - 10;
840-
if (inputWidth < 50) inputWidth = containerWidth;
841+
if (inputWidth < minInputWidth) inputWidth = containerWidth;
841842
ctrl.searchInput.css('width', inputWidth+'px');
842843
return true;
843844
};
844845

845-
ctrl.searchInput.css('width', '10px');
846+
// set width to minimum allowed width plus some padding
847+
// to fit it on the same line as last tag if possible
848+
ctrl.searchInput.css('width', (minInputWidth + 10)+'px');
846849
$timeout(function() { //Give tags time to render correctly
847850
if (sizeWatch === null && !updateIfVisible(calculateContainerWidth())) {
848851
sizeWatch = $scope.$watch(function() {

dist/select.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uiSelectController.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ uis.controller('uiSelectCtrl',
548548

549549
var input = ctrl.searchInput[0],
550550
container = ctrl.searchInput.parent().parent()[0],
551+
minInputWidth = 50,
551552
calculateContainerWidth = function() {
552553
// Return the container width only if the search input is visible
553554
return container.clientWidth * !!input.offsetParent;
@@ -557,12 +558,14 @@ uis.controller('uiSelectCtrl',
557558
return false;
558559
}
559560
var inputWidth = containerWidth - input.offsetLeft - 10;
560-
if (inputWidth < 50) inputWidth = containerWidth;
561+
if (inputWidth < minInputWidth) inputWidth = containerWidth;
561562
ctrl.searchInput.css('width', inputWidth+'px');
562563
return true;
563564
};
564565

565-
ctrl.searchInput.css('width', '10px');
566+
// set width to minimum allowed width plus some padding
567+
// to fit it on the same line as last tag if possible
568+
ctrl.searchInput.css('width', (minInputWidth + 10)+'px');
566569
$timeout(function() { //Give tags time to render correctly
567570
if (sizeWatch === null && !updateIfVisible(calculateContainerWidth())) {
568571
sizeWatch = $scope.$watch(function() {

0 commit comments

Comments
 (0)