Skip to content

Commit

Permalink
[FIX] html_editor: toolbar positioning for mobile
Browse files Browse the repository at this point in the history
Before this commit:

When the keyboard opens on mobile, the toolbar appears in the wrong position,
leaving a space between the toolbar and the keyboard.

After this commit:

Now, when the keyboard opens on mobile, the toolbar will correctly stick to the
top of the keyboard.

task:4196686

closes odoo#181737

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
  • Loading branch information
dhba-odoo committed Oct 29, 2024
1 parent f475c57 commit 7630cc9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/html_editor/static/src/main/toolbar/mobile_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class ToolbarMobile extends Component {
setup() {
this.toolbar = useRef("toolbarWrapper");
useExternalListener(window.visualViewport, "resize", this.fixToolbarPosition);
useExternalListener(window.visualViewport, "scroll", this.fixToolbarPosition);
onMounted(() => {
this.fixToolbarPosition();
});
Expand All @@ -20,7 +21,8 @@ export class ToolbarMobile extends Component {
* Fixes the position of the toolbar for the keyboard height.
*/
fixToolbarPosition() {
const keyboardHeight = window.innerHeight - window.visualViewport.height;
const keyboardHeight =
window.innerHeight - (window.visualViewport.height + window.visualViewport.offsetTop);
if (keyboardHeight > 0) {
this.toolbar.el.style.bottom = `${keyboardHeight}px`;
} else {
Expand Down

0 comments on commit 7630cc9

Please sign in to comment.