Skip to content

Commit d769a0d

Browse files
authored
fix(ui5-multicombobox): Placeholder with tokens hidden (#2785)
Fixes: #2261
1 parent 87520c2 commit d769a0d

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

packages/main/src/MultiComboBox.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<input id="ui5-multi-combobox-input"
3636
.value="{{value}}"
3737
inner-input
38-
placeholder="{{placeholder}}"
38+
placeholder={{_getPlaceholder}}
3939
?disabled={{disabled}}
4040
?readonly={{readonly}}
4141
value-state="{{valueState}}"

packages/main/src/MultiComboBox.js

+8
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,14 @@ class MultiComboBox extends UI5Element {
516516
this.fireSelectionChange();
517517
}
518518

519+
get _getPlaceholder() {
520+
if (this._tokenizer && this._tokenizer.tokens.length) {
521+
return "";
522+
}
523+
524+
return this.placeholder;
525+
}
526+
519527
_handleLeft() {
520528
const cursorPosition = this.getDomRef().querySelector(`input`).selectionStart;
521529

packages/main/test/pages/MultiComboBox.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<span>Validating input and placeholder </span>
108108

109109
<br>
110-
<ui5-multi-combobox placeholder="Some initial text">
110+
<ui5-multi-combobox id="mcb-with-placeholder" placeholder="Some initial text">
111111
<ui5-mcb-item selected text="Cosy"></ui5-mcb-item>
112112
<ui5-mcb-item text="Compact"></ui5-mcb-item>
113113
<ui5-mcb-item selected text="Condensed"></ui5-mcb-item>

packages/main/test/specs/MultiComboBox.spec.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ describe("MultiComboBox general interaction", () => {
222222
});
223223
});
224224

225-
describe("keyboard handling", () => {
225+
describe("General", () => {
226226
browser.url("http://localhost:8080/test-resources/pages/MultiComboBox.html");
227-
228227
it ("tests two-column layout", () => {
229228
const mcb = $("#mcb-two-column-layout");
230229
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#mcb-two-column-layout");
@@ -236,6 +235,14 @@ describe("MultiComboBox general interaction", () => {
236235
assert.strictEqual(listItem.shadow$(".ui5-li-info").getText(), "DZ", "Additional item text should be displayed");
237236
icon.click();
238237
});
238+
239+
it ("placeholder tests", () => {
240+
const mcb1 = browser.$("#another-mcb").shadow$("#ui5-multi-combobox-input");
241+
const mcb2 = browser.$("#mcb-with-placeholder").shadow$("#ui5-multi-combobox-input");
242+
243+
assert.strictEqual(mcb1.getAttribute("placeholder"), "Some initial text", "Should have placeholder");
244+
assert.strictEqual(mcb2.getAttribute("placeholder"), "", "Shouldn't have placeholder when there are tokens");
245+
});
239246
});
240247

241248
describe("ARIA attributes", () => {

0 commit comments

Comments
 (0)