Skip to content

Commit 9b5c7ea

Browse files
committed
fix: single select radio should work with empty label select option
1 parent 256929f commit 9b5c7ea

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

demo/src/options/options02.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ <h2 class="bd-title">
2323

2424
<div>
2525
<div class="mb-3 row">
26-
<label class="col-sm-2"> Basic Select </label>
26+
<label class="col-sm-3">Basic Select</label>
2727

28-
<div class="col-sm-10">
28+
<div class="col-sm-9">
2929
<select class="full-width">
3030
<option value="1">First</option>
3131
<option value="2">Second</option>
@@ -36,9 +36,9 @@ <h2 class="bd-title">
3636
</div>
3737

3838
<div class="mb-3 row">
39-
<label class="col-sm-2"> Group Select </label>
39+
<label class="col-sm-3">Group Select</label>
4040

41-
<div class="col-sm-10">
41+
<div class="col-sm-9">
4242
<select class="full-width">
4343
<optgroup label="Group 1">
4444
<option value="1">Option 1</option>
@@ -58,4 +58,17 @@ <h2 class="bd-title">
5858
</select>
5959
</div>
6060
</div>
61+
62+
<div class="mb-3 row">
63+
<label class="col-sm-3">Single Select with Empty Option</label>
64+
65+
<div class="col-sm-9">
66+
<select class="multiple-select full-width">
67+
<option value=""></option>
68+
<option value="2">Second</option>
69+
<option value="3">Third</option>
70+
<option value="4">Fourth</option>
71+
</select>
72+
</div>
73+
</div>
6174
</div>

lib/src/MultipleSelectInstance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ export class MultipleSelectInstance {
906906

907907
const spanElm = this.choiceElm?.querySelector<HTMLSpanElement>('span');
908908
const sl = valueSelects.length;
909-
let html = '';
909+
let html = null;
910910

911911
const getSelectOptionHtml = () => {
912912
if (this.options.useSelectOptionLabel || this.options.useSelectOptionLabelToHtml) {
@@ -934,7 +934,7 @@ export class MultipleSelectInstance {
934934
html = getSelectOptionHtml();
935935
}
936936

937-
if (html) {
937+
if (html !== null) {
938938
spanElm?.classList.remove('ms-placeholder');
939939
if (this.options.useSelectOptionLabelToHtml) {
940940
spanElm.innerHTML = this.options.sanitizer ? this.options.sanitizer(html) : html;

lib/src/styles/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ $ms-drop-list-item-disabled-filter: Alpha(Opacity = 35) !default;
4141
$ms-drop-list-item-disabled-opacity: 0.35 !default;
4242
$ms-drop-zindex: 1050 !default;
4343
$ms-label-margin-bottom: 0 !default;
44+
$ms-label-min-height: 1.25rem !default;
4445
$ms-label-padding: 0 0 0 1.25rem !default;
4546
$ms-ok-button-bg-color: #fff !default;
4647
$ms-ok-button-bg-hover-color: #f9f9f9 !default;

lib/src/styles/multiple-select.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
position: relative;
250250
white-space: nowrap;
251251
margin-bottom: var(--ms-label-margin-bottom, $ms-label-margin-bottom);
252+
min-height: var(--ms-label-min-height, $ms-label-min-height);
252253
padding: var(--ms-label-padding, $ms-label-padding);
253254

254255
&.optgroup {

0 commit comments

Comments
 (0)