sap.m.Input: bound value is lost (and written back as "" to the model) when updated while busy – regression in 1.154.0 (Control busy getFocusDomRef override)
What is the issue and how can we reproduce it?
Since 1.154.0, a bound sap.m.Input loses its value when the value is updated from the model while the control is busy (setBusy(true)). The <input> element stays empty, and on the next sapfocusleave InputBase.onChange writes "" back to the value property and, with a TwoWay binding, also to the model. As a result, data is lost silently.
This worked in 1.153.0 and earlier versions, and it still reproduces in nightly (1.156.0-SNAPSHOT).
Minimal reproducible example (OpenUI5 only)
Save it as an HTML file and open it, or paste it into JSBin. Switch the version in the bootstrap URL to 1.153.0 to see the expected behavior.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script id="sap-ui-bootstrap"
src="https://sdk.openui5.org/1.154.0/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_horizon"
data-sap-ui-async="true"
data-sap-ui-compat-version="edge"></script>
<script>
sap.ui.require(["sap/ui/core/Core"], (Core) => Core.ready(() => {
sap.ui.require(["sap/m/Input", "sap/m/Button", "sap/ui/model/json/JSONModel"], (Input, Button, JSONModel) => {
const oModel = new JSONModel({ value: "" });
const oInput = new Input("input", { value: "{/value}", busyIndicatorDelay: 0 }).setModel(oModel);
const oOther = new Button("other", { text: "Other" });
oInput.placeAt("content");
oOther.placeAt("content");
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
const state = (step) => ({ step, property: oInput.getValue(), dom: oInput.getDomRef("inner").value, model: oModel.getProperty("/value") });
Core.ready().then(async () => {
await wait(500);
const result = [];
oInput.setBusy(true);
oModel.setProperty("/value", "Hello"); // model update while the Input is busy
await wait(300);
result.push(state("1. while busy, after model update"));
oInput.setBusy(false);
await wait(300);
result.push(state("2. after setBusy(false)"));
oInput.focus(); // user clicks into the field...
await wait(100);
oOther.focus(); // ...and leaves it -> InputBase.onChange
await wait(300);
result.push(state("3. after focus enters and leaves the Input"));
console.table(result);
});
});
}));
</script>
</head>
<body class="sapUiBody"><div id="content"></div></body>
</html>
Result
1.153.0 and earlier (OK):
| step | property | DOM | model |
|---|---|---|---|
| 1. while busy, after model update | Hello |
Hello |
Hello |
| 2. after setBusy(false) | Hello |
Hello |
Hello |
| 3. after focus enters and leaves the Input | Hello |
Hello |
Hello |
1.154.0 and nightly 1.156.0-SNAPSHOT (FAIL):
| step | property | DOM | model |
|---|---|---|---|
| 1. while busy, after model update | "" |
"" |
Hello |
| 2. after setBusy(false) | "" |
"" |
Hello |
| 3. after focus enters and leaves the Input | "" |
"" |
"" |
Expected behavior
A model update must reach the <input> element even while the control is busy, as it did up to 1.153. The Input must never overwrite its own (bound) value with "".
Analysis
1.154.0 introduced createBusyMethodOverrides in sap/ui/core/Control.js. The function is not present in 1.153.0. While the control is busy, it replaces getFocusDomRef() on the instance so that it returns the busy block layer:
// sap/ui/core/Control.js (1.154.0)
oControl.getFocusDomRef = function () {
if (oControl.getBusy() && oControl._oBusyBlockState) {
return oControl._oBusyBlockState.$blockLayer.get(0) || null;
}
return mOriginals.getFocusDomRef.apply(oControl, arguments);
};
However, InputBase.prototype.updateDomValue uses getFocusDomRef() to find the element whose .value it writes:
// sap/m/InputBase.js
InputBase.prototype.updateDomValue = function(sValue) {
var oInnerDomRef = this.getFocusDomRef(); // <-- block layer <div> while busy
...
oInnerDomRef.value = sValue; // <-- value is written to the busy indicator, not to <input>
The sequence is as follows:
- The binding calls
setValue("Hello"). Thevalueproperty andlastValueare set, but"Hello"is written to<div id="input-busyIndicator">and not to<input id="input-inner">. - A
sapfocusleavereaches the Input. In the MRE this already happens while the control is busy, and in a real app it happens when focus moves in or out of the busy indicator or is restored aftersetBusy(false).InputBase.onChangethen reads the empty<input>through_getInputValue(), sees"" !== getLastValue(), and callssetValue(""). A TwoWay binding propagates""to the model.
Stack trace of the setValue("") call (1.154.0):
InputBase.setValue (sap/m/InputBase-dbg.js:1340)
Input.setValue (sap/m/Input-dbg.js:2687)
InputBase.onChange (sap/m/InputBase-dbg.js:643)
InputBase.onsapfocusleave (sap/m/InputBase-dbg.js:576)
Input.onsapfocusleave (sap/m/Input-dbg.js:1581)
Element._handleEvent (sap/ui/core/Element-dbg.js:366)
UIArea._handleEvent (sap/ui/core/UIArea-dbg.js:1057)
triggerFocusleave (sap/ui/core/FocusHandler-dbg.js:412)
Other controls that use getFocusDomRef() to access their own DOM, instead of for focus handling, are probably affected in the same way. For InputBase, a possible fix is to use this.getDomRef("inner") in updateDomValue and handleInputValueConcurrency. Another option is to have the override keep the original getFocusDomRef for internal, non-focus purposes.
Workaround: update the model before calling setBusy(true), or avoid putting a bound Input into the busy state.
Which OpenUI5 version is your project targeting?
1.154.0. The issue is reproducible in 1.154.0 and in nightly 1.156.0-SNAPSHOT. It is not reproducible in 1.153.0, 1.152.1, 1.151.2, 1.150.0, 1.149.1, 1.148.10, 1.147.1, 1.146.0 or 1.145.0.
Is the issue device- or browser-specific?
No. I tested it with:
- Chrome on macOS (desktop): FAIL
- Headless Chromium (Playwright 1.49.1): FAIL
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.
Hello @luizmz94 , Thank you for sharing this finding. I've created an internal incident DINC1129400. The status of the issue will be updated here in GitHub. Kind regards