Skip to content

Commit dd4633e

Browse files
authoredJul 27, 2020
fix(ui5-input): sync width of suggestions popover and input (#1979)
1 parent 7a9e9a3 commit dd4633e

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed
 

‎packages/main/src/Input.js

+3
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,9 @@ class Input extends UI5Element {
10521052
"width": `${this._listWidth}px`,
10531053
"padding": "0.5625rem 1rem",
10541054
},
1055+
suggestionsPopover: {
1056+
"max-width": `${this._inputWidth}px`,
1057+
},
10551058
};
10561059
}
10571060

‎packages/main/src/InputPopover.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
_disable-initial-focus
55
placement-type="Bottom"
66
horizontal-align="Left"
7+
style="{{styles.suggestionsPopover}}"
78
@ui5-after-open="{{_afterOpenPopover}}"
89
@ui5-after-close="{{_afterClosePopover}}"
910
@scroll="{{_scroll}}"

‎packages/main/test/pages/Input.html

+5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ <h3>Input suggestions with highlighing and XSS test</h3>
321321
</ui5-suggestion-item>
322322
</ui5-input>
323323

324+
<h3>Test width of suggestions popover</h3>
325+
<ui5-input id="suggestionsPopoverWidth" show-suggestions style="width: 350px !important;">
326+
<ui5-li>Argentinaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</ui5-li>
327+
</ui5-input>
328+
324329
<script>
325330
var sap_database_entries = [{ key: "A", text: "A" }, { key: "Afg", text: "Afghanistan" }, { key: "Arg", text: "Argentina" }, { key: "Alb", text: "Albania" }, { key: "Arm", text: "Armenia" }, { key: "Alg", text: "Algeria" }, { key: "And", text: "Andorra" }, { key: "Ang", text: "Angola" }, { key: "Ast", text: "Austria" }, { key: "Aus", text: "Australia" }, { key: "Aze", text: "Azerbaijan" }, { key: "Aruba", text: "Aruba" }, { key: "Antigua", text: "Antigua and Barbuda" }, { key: "B", text: "B" }, { key: "Bel", text: "Belarus" }, { key: "Bel", text: "Belgium" }, { key: "Bg", text: "Bulgaria" }, { key: "Bra", text: "Brazil" }, { key: "C", text: "C" }, { key: "Ch", text: "China" }, { key: "Cub", text: "Cuba" }, { key: "Chil", text: "Chili" }, { key: "L", text: "L" }, { key: "Lat", text: "Latvia" }, { key: "Lit", text: "Litva" }, { key: "P", text: "P" }, { key: "Prt", text: "Portugal" }, { key: "S", text: "S" }, { key: "Sen", text: "Senegal" }, { key: "Ser", text: "Serbia" }, { key: "Sey", text: "Seychelles" }, { key: "Sierra", text: "Sierra Leone" }, { key: "Sgp", text: "Singapore" }, { key: "Sint", text: "Sint Maarten" }, { key: "Slv", text: "Slovakia" }, { key: "Slo", text: "Slovenia" }];
326331

‎packages/main/test/specs/Input.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ describe("Input general interaction", () => {
254254
assert.strictEqual(inputResult.getValue(), "", "suggestionItemSelected event is not called");
255255
});
256256

257+
it("checks if the suggestions popover width is the same as the input width when there is a long suggestion", () => {
258+
const input = $("#suggestionsPopoverWidth");
259+
const nativeInput = $("#suggestionsPopoverWidth").shadow$("input");
260+
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#suggestionsPopoverWidth");
261+
const listItem = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover").$("ui5-li-suggestion-item");
262+
263+
nativeInput.click();
264+
265+
assert.strictEqual(input.getSize('width'), listItem.getSize('width'));
266+
})
267+
257268
it("Input's maxlength property is set correctly", () => {
258269
const input5 = $("#input-tel");
259270
const inputShadowRef = $("#input-tel").shadow$("input");

0 commit comments

Comments
 (0)
Please sign in to comment.