odoo/odoo#64382

Created by fw-bot
Merged at 08d228546911ef4c9aa35d301057f9000bc302d6

Statuses:

label
odoo-dev:saas-14.1-14.0-web-colorpicker-unknown-cors-error-safari-fix-sad-X362-fw
head
c80d2d440a8edd700788f5632a6c1993446092cf
merged
5 years ago by Quentin Smetz (qsm)
odoo/odoo
14.0 #64244
saas-14.1 #64382
16.0
17.0
18.0
saas-18.2
saas-18.3
saas-18.4
19.0
saas-19.1
saas-19.2
master #64389

[FW][FIX] web: fix colorpicker "unknown CORS error" on safari

Previously, when opening a colorpicker in safari, the crash manager
would open with the message "An unknown CORS error occured [...]". This
is actually odoo's default message when an error has no file, line or
column, which is usually the case for security reasons on CORS error.
This is however not a true CORS error, but a "ResizeObserver loop
completed with undelivered notifications" error, which also does not
report file, line and col for the error.

This error is caused by the fact that in webkit, the baseline of an
empty input is considered to be at the bottom of the input element,
rather than at the baseline of the text of the input once it has some
content. (see https://bugs.webkit.org/show_bug.cgi?id=142968 )

In the case of the colorpicker, it uses a ResizeObserver to update its
UI, including updating the content of its inputs. This will cause the
first _updateUI to fill the empty inputs, which changes the layout of
the widget content and changes its size. Changing the size of an element
inside of a handler of a ResizeObserver on that same element will cause
an error and not call the callback again, so as to prevent infinite
loop.

This commit fixes that by filling the inputs before attaching the
ResizeObserver, so that it has its final size from the get-go, and
_updateUI will no longer change the layout/size, causing this error.

opw-2419296

Forward-Port-Of: #64244