sap.ui.mdc.table.utils.FilterInfoBar logs "Assertion failed: oDelegate must be not null or undefined"
What is the issue and how can we reproduce it?
sap.ui.mdc.table.utils.FilterInfoBar logs "Assertion failed: oDelegate must be not null or undefined"
Minimal reproduction for a bug in sap.ui.mdc.table.utils.FilterInfoBar (OpenUI5 / SAPUI5 sap.ui.mdc, reproduced on 1.148.3).
Github Repo
Applying any filter personalization (p13nMode="Filter") on an sap.ui.mdc.Table - with or without an attached mdc.FilterBar - logs three console.assert failures the first time the table's FilterInfoBar is constructed:
Assertion failed: oDelegate must be not null or undefined
Filtering itself keeps working correctly (see screenshot below) - this is a logging-only defect, but it pollutes the console on every app that uses MDC table filtering, and can mask real assertion failures during development.
Root cause
sap.ui.mdc.table.utils.FilterInfoBar extends sap.m.Toolbar, but its init() never calls the parent Toolbar.prototype.init:
// sap/ui/mdc/table/utils/FilterInfoBar.js
FilterInfoBar.prototype.init = function() {
this.oText = new Text({wrapping: false});
this.oInvisibleText = new InvisibleText().toStatic();
this.oRemoveAllFiltersBtn = new Button({ /* ... */ });
this.setDesign("Info");
this.setActive(true);
this.addContent(this.oText); // <-- Toolbar#addContent, before Toolbar#init ever ran
this.addContent(new ToolbarSpacer());
this.addContent(this.oRemoveAllFiltersBtn);
this.addDependent(this.oInvisibleText);
// ...
};
Toolbar.prototype.init is where sap.m.Toolbar sets up its content-delegate reference:
// sap/m/Toolbar.js
Toolbar.prototype.init = function () {
// ...
this._oContentDelegate = {
onAfterRendering: this._onAfterContentRendering
};
};
Because FilterInfoBar.init() overrides init() without ever calling (or apply-ing) Toolbar.prototype.init, this._oContentDelegate is always undefined on a FilterInfoBar instance. Each of the three addContent() calls above goes through Toolbar.prototype._onContentInserted:
// sap/m/Toolbar.js
Toolbar.prototype._onContentInserted = function(oControl) {
if (oControl) {
oControl.attachEvent("_change", this._onContentPropertyChanged, this);
oControl.addEventDelegate(this._oContentDelegate, oControl); // <-- undefined
}
};
...which calls sap.ui.core.Element#addDelegate with oDelegate === undefined, tripping the assertion:
// sap/ui/core/Element.js
Element.prototype.addDelegate = function (oDelegate, bCallBefore, oThis, bClone) {
assert(oDelegate, "oDelegate must be not null or undefined");
// ...
};
assert() only logs in non-optimized builds and never throws, so nothing actually breaks - the three content controls (Text, ToolbarSpacer, Button) simply never get their onAfterRendering content-delegate wired up. FilterInfoBar is constructed lazily by Table.prototype.setFilterConditions -> updateFilterInfoBar() the first time filter conditions become non-empty, for any table with p13nMode including "Filter" - independent of whether an external FilterBar is attached.
Suggested fix
Call the parent init() at the top of FilterInfoBar.prototype.init, e.g.:
FilterInfoBar.prototype.init = function() {
Toolbar.prototype.init.apply(this, arguments);
// ... rest unchanged
};
Steps to reproduce (this repository)
npm install
npm start
Open the app, then:
- Click the table's Settings (gear) icon.
- Switch to the Filter tab.
- In the "Filter by" dropdown, pick Category.
- Type
Furnitureinto the new Category field and press Enter. - Click OK.
- Open the browser console.
Expected: no console output related to addDelegate.
Actual: three lines of
Assertion failed: oDelegate must be not null or undefined
(table filtering itself works correctly - only "Furniture" rows remain).
Where the bug is not
This reproduction deliberately has no mdc.FilterBar attached to the table (p13nMode="Sort,Column,Filter" only, see webapp/view/Main.view.xml) - the table builds its own private "inbuilt" filter bar for the Adapt Filters dialog in that case. The bug is unrelated to that: it reproduces identically with an external FilterBar attached, since FilterInfoBar construction is triggered purely by Table#setFilterConditions becoming non-empty, regardless of the source of the filter.
Environment
- OpenUI5 1.148.3 (
https://sdk.openui5.org/1.148.3) - Reproduced in Chrome (Windows)
sap.ui.mdc.Table,type="ResponsiveTable"
Additional Information
In the console log you'll see another error message, which should be corrected, too:
(dependency of 'sap/ui/mdc/p13n/panels/AdaptFiltersPanelContent.js') Importing the pseudo module 'sap/m/ListKeyboardMode' is deprecated. To access the type 'sap.m.ListKeyboardMode', please import 'sap/m/library'. You can then reference this type via the library's module export. For more information, see documentation under 'Best Practices for Loading Modules'. - sap.ui.ModuleSystem
Which OpenUI5 version is your project targeting?
1.148
Is the issue device- or browser-specific?
No response
Confirmation
- [x] I have searched the existing issues and reviewed the relevant documentation as well as the API reference.
- [x] I am not disclosing any internal or sensitive information.
Hi @se38, thank you for sharing this finding. I've created an internal incident DINC1039562. The status of the issue will be updated here in GitHub.
Hi, thanks for reporting this issue. The fix will be in the next release.
There won't be a downport, though. Our downport policies are quite strict and this is "just" a log entry without functional impact in the scope these controls are being used in.
@JumpNRun Hi Alexander, when you say "next release", does it mean "next major release 1.xxx" or a "next patch release 1.148.x"? Cheers, Uwe
Hi, I meant the next major release 1.154