Posted 17 November 2022, 10:25 pm EST
When a callback is provided as the second argument to setTimeout, zero, the callback will be scheduled to run asynchronously and with the smallest possible delay.
When the Invalid Operation occurs, there is a race condition between your code to make SpreadJS the focus and the attempt to modify the Dialog Popup message and show it. And when the Dialog Warning is displayed, the code to make SpreadJS the focus will once again cause SpreadJS to lose this race (current behavior).
SetTimeout(cb, 0) causes SpreadJS to focus in the shortest amount of time while the Dialog Warning is already displayed up until that point. When spread.focus(false) is used, it causes the SpreadJS to lose focus, which is the desired outcome.