Skip to content

Commit 7743bc3

Browse files
authored
fix: any min/max width options should be applied to drop CSS style (#402)
1 parent fa405af commit 7743bc3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/multiple-select-vanilla/src/MultipleSelectInstance.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,15 @@ export class MultipleSelectInstance {
241241

242242
this.closeElm = this.choiceElm.querySelector('.ms-icon-close');
243243

244-
if (this.options.dropWidth) {
245-
this.dropElm.style.width = typeof this.options.dropWidth === 'string' ? this.options.dropWidth : `${this.options.dropWidth}px`;
244+
// any of the drop width options provided should apply them to the associated drop style
245+
const styleOptions = ['minWidth', 'maxWidth', 'width', 'dropWidth'] as unknown as Array<keyof MultipleSelectOption>;
246+
for (const stlOption of styleOptions) {
247+
if (this.options[stlOption]) {
248+
// options.dropWidth needs to be aliased to style.width, anything else are the same prop/style name
249+
const styleProp = stlOption === 'dropWidth' ? 'width' : (stlOption as 'minWidth' | 'maxWidth' | 'width');
250+
this.dropElm.style[styleProp] =
251+
typeof this.options[stlOption] === 'string' ? this.options[stlOption] : `${this.options[stlOption]}px`;
252+
}
246253
}
247254

248255
insertAfter(this.elm, this.parentElm);

0 commit comments

Comments
 (0)