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

Commit 47b55d1

Browse files
committed
Fix for appendToBody support: remember the original inline style width of the select element, so that it can be properly restored after it gets moved back to its original location.
1 parent ed61077 commit 47b55d1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/uiSelectDirective.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ uis.directive('uiSelect',
181181
}
182182

183183
// Hold on to a reference to the .ui-select-container element for appendToBody support
184-
var placeholder = null;
184+
var placeholder = null,
185+
originalWidth = '';
185186

186187
function positionDropdown() {
187188
// Remember the absolute position of the element
@@ -193,6 +194,10 @@ uis.directive('uiSelect',
193194
placeholder[0].style.height = offset.height + 'px';
194195
element.after(placeholder);
195196

197+
// Remember the original value of the element width inline style, so it can be restored
198+
// when the dropdown is closed
199+
originalWidth = element[0].style.width;
200+
196201
// Now move the actual dropdown element to the end of the body
197202
$document.find('body').append(element);
198203

@@ -215,7 +220,7 @@ uis.directive('uiSelect',
215220
element[0].style.position = '';
216221
element[0].style.left = '';
217222
element[0].style.top = '';
218-
element[0].style.width = '';
223+
element[0].style.width = originalWidth;
219224
}
220225

221226
// Move transcluded elements to their correct position in main template

0 commit comments

Comments
 (0)