-
Notifications
You must be signed in to change notification settings - Fork 116
[FIX] html_editor: update font size selector on set tag in toolbar #4777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master-mysterious-egg-next
Are you sure you want to change the base?
[FIX] html_editor: update font size selector on set tag in toolbar #4777
Conversation
This PR targets the un-managed branch odoo-dev/odoo:master-mysterious-egg-next, it needs to be retargeted before it can be merged. |
@robodoo r+ |
Branch |
@robodoo r- |
Branch |
Didn't realize it wasn't for master |
It looks good, I'll wait for the tests to go green. One small issue:
|
9c49b9e
to
7d3fffc
Compare
import { | ||
removeClass, | ||
removeStyle, | ||
unwrapContents, | ||
wrapInlinesInBlocks, | ||
splitTextNode, | ||
} from "../utils/dom"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just linting.
37253b5
to
a668b51
Compare
@robinlej Thanks for reviewing. I fixed the issue you raised and in doing so I changed approaches entirely (because it couldn't be solved with the other approach). I added a note in the commit message on future work that might be needed because I lack proper context to know exactly what is or isn't expected in terms of re-rendering of Owl components in the context of Since it touches on some editor specific stuff, I thought it would be best for one of our own to review it too. @sébastien (sge) and I discussed it IRL, I made some more changes, and he approved the approach. |
In website builder: 1. Select text 2. Change heading type in the toolbar -> the font size selector in the toolbar is blank. This is because the font size input is in an iframe, and a chain of events triggered by changing the heading type (`setTag`) leads to the iframe's document to be re-rendered. This only happens in the website builder because of a call to `updateContainers` as a step_added handler that triggers the `change_current_options_containers_listeners`. These listeners are triggered because `setTag` replaced the block which was the target of the `BuilderOptionsPlugin` with another. We have a method for when such a reference has changed and it bears a risk of breaking the selection: `preserveSelection`'s `remapNode. This binds it to `BuilderOptionsPlugin` so it can update its target in such a case. This way the target is not lost, the iframe is not re-rendered, and the toolbar is intact. Note: broader work might be needed to investigate whether it is normal that the iframe gets re-rendered, and if so, to guarantee that the input never gets lost in the process.
a668b51
to
2ab5b63
Compare
@robinlej Do you know who wrote odoo/addons/html_builder/static/src/core/builder_options_plugin.js Lines 115 to 121 in 2e9b9d5
If we were to remove Removing odoo/addons/html_builder/static/src/core/builder_options_plugin.js Lines 118 to 120 in 2e9b9d5
So was there a reason for it or can these lines be removed? cc @sebgeelen |
Many hands have been involved around From the look of it, it seems mainly there to avoid frequent computations while we can just rely on the last known containers. We could test to see if there's a performance cost to removing it. |
In website builder:
-> the font size selector in the toolbar is blank:
This is because the font size input is in an iframe, and a chain of events triggered by chaning the heading type leads to the iframe's document to be re-rendered. This only happens in the website builder because of a call to
updateContainers
as a step_added handler.This commit fixes it by rendering the input in a
useEffect
hook instead ofonMounted
, and checking that the input is mounted before re-rendering it as well.