From 5a82426ed23724a1860bb7b5efa3e28326512716 Mon Sep 17 00:00:00 2001 From: Ryan Schmukler Date: Tue, 24 Feb 2015 11:01:30 -0500 Subject: [PATCH] fix(select): fix select with 0 options positioning closes #1618 --- src/components/select/demoBasicUsage/script.js | 1 + src/components/select/select.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/select/demoBasicUsage/script.js b/src/components/select/demoBasicUsage/script.js index 32797f9299a..07c2a94a48d 100755 --- a/src/components/select/demoBasicUsage/script.js +++ b/src/components/select/demoBasicUsage/script.js @@ -1,5 +1,6 @@ angular.module('selectDemoBasic', ['ngMaterial']) .controller('AppCtrl', function($scope) { $scope.neighborhoods = ['Chelsea', 'Financial District', 'Midtown', 'West Village', 'Williamsburg']; + $scope.neighborhoods = []; $scope.neighborhoods2 = ['Chelsea', 'Financial District', 'Lower Manhattan', 'Midtown', 'Soho', 'Upper Manhattan', 'West Village', 'Williamsburg' ]; }); diff --git a/src/components/select/select.js b/src/components/select/select.js index e9d83057281..788147ef56b 100755 --- a/src/components/select/select.js +++ b/src/components/select/select.js @@ -673,7 +673,7 @@ function SelectProvider($$interimElementProvider) { centeredNode = optionNodes[Math.floor(optionNodes.length / 2 )]; // In case there are no options, center on whatevers in there... (such as a progress indicator) } else { - centeredNode = contentNode.firstElementChild; + centeredNode = contentNode.firstElementChild || contentNode; } if (contentNode.offsetWidth > maxWidth) {