diff --git a/packages/main/src/Input.js b/packages/main/src/Input.js index 279d45bf82b9..e6390352c55e 100644 --- a/packages/main/src/Input.js +++ b/packages/main/src/Input.js @@ -862,6 +862,20 @@ class Input extends UI5Element { return this.suggestionItems[key]; } + /** + * Returns if the suggestions popover is scrollable. + *

+ * Note: the method is async + * @returns {boolean} true if the popover is scrollable, false otherwise + */ + async isSuggestionsScrollable() { + if (!this.Suggestions) { + return false; + } + + return (await this.Suggestions._isScrollable()); + } + getInputId() { return `${this._id}-inner`; } diff --git a/packages/main/src/features/InputSuggestions.js b/packages/main/src/features/InputSuggestions.js index 4c995c635c80..95b838eb7875 100644 --- a/packages/main/src/features/InputSuggestions.js +++ b/packages/main/src/features/InputSuggestions.js @@ -102,6 +102,11 @@ class Suggestions { } } + async _isScrollable() { + const sc = await this._getScrollContainer(); + return sc.offsetHeight < sc.scrollHeight; + } + async open() { this.responsivePopover = await this._respPopover(); this._beforeOpen(); diff --git a/packages/main/test/pages/Input.html b/packages/main/test/pages/Input.html index c64766040eb0..ebf14820e271 100644 --- a/packages/main/test/pages/Input.html +++ b/packages/main/test/pages/Input.html @@ -314,7 +314,7 @@

Test ariaLabel and ariaLabelledBy

var suggestionSelectedCounterWithGrouping = 0; - var suggest = function (event) { + var suggest = async function (event) { var input = event.target; var value = input.value; var suggestionItems = []; @@ -342,6 +342,11 @@

Test ariaLabel and ariaLabelledBy

}); labelLiveChange.innerHTML = "Event [input] :: " + value; + + await window.RenderScheduler.whenFinished(); + const scrollable = await input.isSuggestionsScrollable(); + + console.log("Suggestions are scrollable", scrollable); }; input.addEventListener("ui5-input", suggest); diff --git a/packages/main/test/specs/Input.spec.js b/packages/main/test/specs/Input.spec.js index c4f6acad2750..59fbc383feeb 100644 --- a/packages/main/test/specs/Input.spec.js +++ b/packages/main/test/specs/Input.spec.js @@ -143,12 +143,11 @@ describe("Input general interaction", () => { const input = $("#scrollInput").shadow$("input"); const scrollResult = $("#scrollResult"); - // act - // open suggestions + // act - open suggestions input.click(); input.keys("a"); - // scroll with keyboard + // act - scroll with keyboard input.keys("ArrowUp"); input.keys("ArrowUp"); input.keys("ArrowUp"); @@ -157,7 +156,16 @@ describe("Input general interaction", () => { const scrollTop = scrollResult.getProperty("value"); assert.ok(scrollTop > 0, "The suggestion-scroll event fired"); - input.keys("Enter"); // close suggestions + // assert isSuggestionsScrollable + const suggestionsScrollable = browser.execute(async () => { + const input = document.getElementById("scrollInput"); + await window.RenderScheduler.whenFinished(); + return await input.isSuggestionsScrollable(); + }); + assert.equal(suggestionsScrollable, true, "The suggestions popup is scrolalble"); + + // close suggestions + input.keys("Enter"); }); it("handles suggestions", () => {