From 7285faebf27165d4e72af289dce50bda105a54fd Mon Sep 17 00:00:00 2001 From: Iliana Bobeva Date: Fri, 8 Dec 2023 17:00:49 +0200 Subject: [PATCH] [FIX] sap.uxap.ObjectPageSubSection: Fix non-expanding Table Problem: sap.ui.table.Table is not expanded in a SubSection with sapUxAPObjectPageSubSectionFitContainer class. What happens is: 1. OPL is rendered, SubSection receives the sapUxAPObjectPageSubSectionFitContainer class and calculates its own height. Fixed height is set. 2. Table calculates how much rows it can show in Auto mode. Fixed height is set. 3. headerTitle of OPL is changed and now it has bigger height. 4. SubSection adjusts its height, but as the Table has already taken up the whole available space and shows maximum possible number of rows, the SubSection detects that its scrollHeight is bigger than its height (scroll is needed). It sets auto height. 5. Table adjusts its visible rows count in order to fill up the new available space and again fits in the SubSection, without scrollbar needed. Auto height is set, as the parent container is also with auto height. 6. However, when SubSection set auto height, it does not save it in the _height private property. So that, when .setHeight is called again with the previously calculated height, the setHeight function returns and does not call _adaptDomHeigt. 7. As adaptDomHeight is not called, fixed height is not set to the SubSection and now it still has auto height. As a result, its height is equal to the height of the Table with minRowCount --> the Table does not expand any more. Solution: Save the auto height in the private _height property, so we can set fixed height later, if needed (something has changed --> Table has adjusted itself). BCP: 2370133187 SNOW: CS20240007584409 Change-Id: I3de9c59fd54ad094ef487fe99d73d8448ccf90ae (cherry picked from commit 0c93e626305d58f91bafa8953acca6dd13bac7d4) CR-Id: 002075125900002194992024 --- .../src/sap/uxap/ObjectPageSubSection.js | 1 + .../uxap/qunit/ObjectPageSubSection.qunit.js | 44 +++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/sap.uxap/src/sap/uxap/ObjectPageSubSection.js b/src/sap.uxap/src/sap/uxap/ObjectPageSubSection.js index c55b32389863..8bd48f3534bc 100644 --- a/src/sap.uxap/src/sap/uxap/ObjectPageSubSection.js +++ b/src/sap.uxap/src/sap/uxap/ObjectPageSubSection.js @@ -660,6 +660,7 @@ sap.ui.define([ containerHeight = Math.ceil(parseFloat(defaultSectionHeight)); oDom.style.height = (contentHeight > containerHeight) ? "" : defaultSectionHeight; + this._height = oDom.style.height; } }; diff --git a/src/sap.uxap/test/sap/uxap/qunit/ObjectPageSubSection.qunit.js b/src/sap.uxap/test/sap/uxap/qunit/ObjectPageSubSection.qunit.js index 6454d7e758f8..77a449b123fa 100644 --- a/src/sap.uxap/test/sap/uxap/qunit/ObjectPageSubSection.qunit.js +++ b/src/sap.uxap/test/sap/uxap/qunit/ObjectPageSubSection.qunit.js @@ -19,8 +19,9 @@ sap.ui.define([ "sap/m/Label", "sap/m/Panel", "sap/m/Text", + "sap/m/Title", "sap/ui/core/HTML"], -function($, Core, Control, coreLibrary, XMLView, Log, Lib, ObjectPageDynamicHeaderTitle, ObjectPageSection, ObjectPageSectionBase, ObjectPageSubSectionClass, BlockBase, ObjectPageLayout, library, App, Button, Label, Panel, Text, HTML) { +function($, Core, Control, coreLibrary, XMLView, Log, Lib, ObjectPageDynamicHeaderTitle, ObjectPageSection, ObjectPageSectionBase, ObjectPageSubSectionClass, BlockBase, ObjectPageLayout, library, App, Button, Label, Panel, Text, Title, HTML) { "use strict"; var TitleLevel = coreLibrary.TitleLevel; @@ -980,6 +981,7 @@ function($, Core, Control, coreLibrary, XMLView, Log, Lib, ObjectPageDynamicHead }) ] }), + oApp = new App({pages: [opl]}), oSpy = this.spy(Log, "error"), oSetParentSpy, done = assert.async(); @@ -1000,11 +1002,11 @@ function($, Core, Control, coreLibrary, XMLView, Log, Lib, ObjectPageDynamicHead assert.strictEqual(oSubSection.getBlocks().length, 2, "ObjectPageSubSection has two controls in 'blocks' aggregation"); done(); oSubSection.removeAllDependents(); - opl.destroy(); + oApp.destroy(); } }); - new App({pages: [opl]}).placeAt("qunit-fixture"); + oApp.placeAt("qunit-fixture"); Core.applyChanges(); }); @@ -1605,6 +1607,42 @@ function($, Core, Control, coreLibrary, XMLView, Log, Lib, ObjectPageDynamicHead }, this); }); + QUnit.test("height of single subSection with sapUxAPObjectPageSubSectionFitContainer adjusts with headerTitle adjusments", function(assert) { + var oPage = this.oObjectPage, + oSection = this.oObjectPage.getSections()[0], + oSubSection = oSection.getSubSections()[0], + oBlock = oSubSection.getBlocks()[0], + done = assert.async(); + + assert.expect(2); + + //act + oBlock.setHeight("845px"); + oPage.setHeaderTitle(new ObjectPageDynamicHeaderTitle({ + heading: new Title({ text: "Title" }) + })); + Core.applyChanges(); + oSubSection.addStyleClass(ObjectPageSubSectionClass.FIT_CONTAINER_CLASS); + + //setup + oPage.attachEventOnce("onAfterRenderingDOMReady", function() { + //check + var sHeight = oSubSection._height; + assert.strictEqual(sHeight, "", "Height is auto when content is bigger than SubSection's height"); + + //act + oPage.destroyHeaderTitle(); + + oPage.attachEventOnce("onAfterRenderingDOMReady", function () { + var sNewHeight = oSubSection._height; + assert.ok(sHeight !== sNewHeight, "Fixed height is changed when headerTitle is added/removed"); + + done(); + }); + Core.applyChanges(); + }, this); + }); + QUnit.test("sapUxAPObjectPageSubSectionFitContainer class can be added late", function (assert) { var oPage = this.oObjectPage, oSection = this.oObjectPage.getSections()[0],