Skip to content

Commit

Permalink
[FIX] sap.uxap.ObjectPageSubSection: Fix non-expanding Table
Browse files Browse the repository at this point in the history
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 0c93e62)
CR-Id: 002075125900002194992024
  • Loading branch information
IlianaB authored and kineticjs committed Jun 20, 2024
1 parent 5e09d9c commit 7285fae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/sap.uxap/src/sap/uxap/ObjectPageSubSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ sap.ui.define([
containerHeight = Math.ceil(parseFloat(defaultSectionHeight));

oDom.style.height = (contentHeight > containerHeight) ? "" : defaultSectionHeight;
this._height = oDom.style.height;
}
};

Expand Down
44 changes: 41 additions & 3 deletions src/sap.uxap/test/sap/uxap/qunit/ObjectPageSubSection.qunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
});

Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 7285fae

Please sign in to comment.