[JS] Run the named actions before running the format when the file is open (issue #15818)

It's a follow-up of #14950: some format actions are ran when the document is open
but we must be sure we've everything ready for that, hence we have to run some
named actions before runnig the global format.
In playing with the form, I discovered that the blur event wasn't triggered when
JS called `setFocus` (because in such a case the mouse was never down). So I removed
the mouseState thing to just use the correct commitKey when blur is triggered by a
TAB key.
This commit is contained in:
Calixte Denizet 2022-12-13 16:08:36 +01:00
parent 2d596045d1
commit 2ebf8745a2
11 changed files with 182 additions and 159 deletions

View file

@ -91,6 +91,10 @@ class EventDispatcher {
if (id === "doc") {
const eventName = event.name;
if (eventName === "Open") {
// Initialize named actions before calling formatAll to avoid any
// errors in the case where a formatter is using one of those named
// actions (see #15818).
this._document.obj._initActions();
// Before running the Open event, we format all the fields
// (see bug 1766987).
this.formatAll();
@ -264,6 +268,7 @@ class EventDispatcher {
value: "",
formattedValue: null,
selRange: [0, 0],
focus: true, // Stay in the field.
});
}
}