Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-input): sync width of suggestions popover and input #1979

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ class Input extends UI5Element {
"width": `${this._listWidth}px`,
"padding": "0.5625rem 1rem",
},
suggestionsPopover: {
"max-width": `${this._inputWidth}px`,
},
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/main/src/InputPopover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
_disable-initial-focus
placement-type="Bottom"
horizontal-align="Left"
style="{{styles.suggestionsPopover}}"
@ui5-after-open="{{_afterOpenPopover}}"
@ui5-after-close="{{_afterClosePopover}}"
@scroll="{{_scroll}}"
Expand Down
5 changes: 5 additions & 0 deletions packages/main/test/pages/Input.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ <h3>Input suggestions with highlighing and XSS test</h3>
</ui5-suggestion-item>
</ui5-input>

<h3>Test width of suggestions popover</h3>
<ui5-input id="suggestionsPopoverWidth" show-suggestions style="width: 350px !important;">
<ui5-li>Argentinaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</ui5-li>
</ui5-input>

<script>
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" }];

Expand Down
11 changes: 11 additions & 0 deletions packages/main/test/specs/Input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ describe("Input general interaction", () => {
assert.strictEqual(inputResult.getValue(), "", "suggestionItemSelected event is not called");
});

it("checks if the suggestions popover width is the same as the input width when there is a long suggestion", () => {
const input = $("#suggestionsPopoverWidth");
const nativeInput = $("#suggestionsPopoverWidth").shadow$("input");
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#suggestionsPopoverWidth");
const listItem = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover").$("ui5-li-suggestion-item");

nativeInput.click();

assert.strictEqual(input.getSize('width'), listItem.getSize('width'));
})

it("Input's maxlength property is set correctly", () => {
const input5 = $("#input-tel");
const inputShadowRef = $("#input-tel").shadow$("input");
Expand Down