jsf.js_next_gen 4.1.0-beta.16 → 4.1.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/window/faces-development.js +20 -8
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +20 -8
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.map +1 -1
- package/package.json +2 -2
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +115 -0
package/README.md
CHANGED
|
@@ -281,6 +281,21 @@ Tests
|
|
|
281
281
|
- Added tests for HiddenInputBuilder, Lang, and async queue
|
|
282
282
|
|
|
283
283
|
|
|
284
|
+
## 4.1.0-beta.17
|
|
285
|
+
|
|
286
|
+
- Bugfix: caret position regression on partial updates
|
|
287
|
+
- After typing into an input that triggers an ajax request, the keyboard caret jumped to
|
|
288
|
+
the beginning of the field (e.g. typing `123` resulted in `321`). This regressed in
|
|
289
|
+
`mona-dish` `0.50.0-beta.3`'s caret restoration and is fixed there; the focused input now
|
|
290
|
+
keeps its caret whether a partial response re-renders a different component or the input
|
|
291
|
+
itself.
|
|
292
|
+
- Dependency update
|
|
293
|
+
- Updated `mona-dish` to `0.50.0-beta.3`
|
|
294
|
+
- Tests added
|
|
295
|
+
- Added two protocol-level regression tests (`ResponseTest`) reproducing the Tobago
|
|
296
|
+
`<tc:in>`/`<tc:out>` scenario: typing `123` keeps the caret in order for both the
|
|
297
|
+
"re-render only the output" and the "re-render the input itself" cases.
|
|
298
|
+
|
|
284
299
|
## 4.1.0-beta.16
|
|
285
300
|
|
|
286
301
|
- Dependency update
|
|
@@ -1827,11 +1827,16 @@ class DomQuery {
|
|
|
1827
1827
|
if (this.isAbsent()) {
|
|
1828
1828
|
return undefined;
|
|
1829
1829
|
}
|
|
1830
|
-
let
|
|
1831
|
-
let
|
|
1830
|
+
let toReplace = this.getAsElem(0).value;
|
|
1831
|
+
let activeElement = document === null || document === void 0 ? void 0 : document.activeElement;
|
|
1832
|
+
let focusElementId = activeElement === null || activeElement === void 0 ? void 0 : activeElement.id;
|
|
1833
|
+
// only save/restore the caret if the focused element is actually part of the
|
|
1834
|
+
// subtree that gets replaced. Otherwise updating an unrelated component would
|
|
1835
|
+
// reset the caret of a different, still focused input field.
|
|
1836
|
+
let restoreFocus = !!focusElementId && !!((_a = toReplace === null || toReplace === void 0 ? void 0 : toReplace.contains) === null || _a === void 0 ? void 0 : _a.call(toReplace, activeElement));
|
|
1837
|
+
let caretPosition = restoreFocus ? DomQuery.getCaretPosition(activeElement) : null;
|
|
1832
1838
|
let nodes = DomQuery.fromMarkup(markup);
|
|
1833
1839
|
let res = [];
|
|
1834
|
-
let toReplace = this.getAsElem(0).value;
|
|
1835
1840
|
let firstInsert = nodes.get(0);
|
|
1836
1841
|
let parentNode = toReplace.parentNode;
|
|
1837
1842
|
let replaced = firstInsert.getAsElem(0).value;
|
|
@@ -1852,10 +1857,12 @@ class DomQuery {
|
|
|
1852
1857
|
if (runEmbeddedCss) {
|
|
1853
1858
|
this.runCss();
|
|
1854
1859
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1860
|
+
if (restoreFocus) {
|
|
1861
|
+
let focusElement = DomQuery.byId(focusElementId);
|
|
1862
|
+
if (focusElement.isPresent() &&
|
|
1863
|
+
caretPosition != null && "undefined" != typeof caretPosition) {
|
|
1864
|
+
focusElement.eachElem(item => DomQuery.setCaretPosition(item, caretPosition));
|
|
1865
|
+
}
|
|
1859
1866
|
}
|
|
1860
1867
|
return nodes;
|
|
1861
1868
|
}
|
|
@@ -2327,7 +2334,12 @@ class DomQuery {
|
|
|
2327
2334
|
static getCaretPosition(ctrl) {
|
|
2328
2335
|
let caretPos = 0;
|
|
2329
2336
|
try {
|
|
2330
|
-
if (
|
|
2337
|
+
if (typeof (ctrl === null || ctrl === void 0 ? void 0 : ctrl.selectionStart) === "number") {
|
|
2338
|
+
// modern browsers expose the caret position directly via selectionStart
|
|
2339
|
+
caretPos = ctrl.selectionStart;
|
|
2340
|
+
}
|
|
2341
|
+
else if (document === null || document === void 0 ? void 0 : document.selection) {
|
|
2342
|
+
// legacy IE fallback
|
|
2331
2343
|
ctrl.focus();
|
|
2332
2344
|
let selection = document.selection.createRange();
|
|
2333
2345
|
// the selection now is start zero
|