Skip to content

Conversation

@dhrp-odoo
Copy link
Contributor

Description:

Pressing Tab in the font size editor moves focus to the hidden “add more rows” footer (the next focusable element in the DOM). This caused the browser to auto-scroll to the footer while the grid viewport state remained unchanged, making the footer appear to float over the grid.

Now, when the font size editor loses focus (via blur/Tab), it closes its dropdown and redirects focus back to the grid instead of the footer.

Task: 5263792

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Nov 20, 2025

Pull request status dashboard

input.focus();
await nextTick();
expect(fixture.querySelector(".o-dropdown-content.o-text-options")).toBeTruthy();
input.blur();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think jsdom doesn’t implement real Tab-based focus navigation, so we call blur() directly here to reliably trigger the blur handler in this test.

const isOpen = this.dropdown.isOpen;
if (!isOpen) {
this.props.onToggle();
this.inputRef.el!.focus();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this ? don't we want the input focused when clicking on the arrow ?

Copy link
Contributor Author

@dhrp-odoo dhrp-odoo Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if we keep the font editor input focused when clicking the arrow, the dropdown becomes impossible to close.
When we click the arrow to close it, the input first triggers a blur event (which closes the dropdown), and then the click handler on the arrow runs and opens it again. Since blur happens before click, the two handlers cancel each other out.

I tried the mousedown event as well (as it is called before the blur), but then we need to replace all the click events with mousedown in this component. I am not sure if that is good or not.

If we really want the focus on the font editor input, then I guess better to remove the blur handler and directly handle the Tab event inside the component? What do you think? Let me know if you have a better approach

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah this sounds annoying ... maybe we could close the dropwdown on an external click event rather than on blur ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s already handled; I just also wanted it to close when we press Tab in the font size input, so focus returns to the grid, which selects the cell and moves to the right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So handling tab manually with a prevent default should do the trick I guess. Not that pretty but 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried all the other approaches but couldn’t find anything better. All the solutions feel hacky (creating a boolean to skip the calls, applying mousedowns)

@dhrp-odoo dhrp-odoo force-pushed the 17.0-tab-navigation-breaks-layout-dhrp branch from b3b7064 to d7c7704 Compare November 25, 2025 13:10
Pressing Tab in the font size editor could move focus to the hidden
“add more rows” footer. The browser then auto-scrolled to that footer
while the grid viewport state stayed unchanged, making the footer look
like it was floating above the grid.

We now handle Tab on the font size input: we prevent the default
navigation, close the dropdown, and redirect focus back to the grid
composer instead of the footer. This keeps the layout stable when
tabbing from the toolbar.

Alternative approaches considered but discarded:

- Closing on blur and refocusing the grid: clicking the arrow caused
  the input to blur first, so the blur handler closed the dropdown and
  the arrow click immediately reopened it, making it impossible to
  close the dropdown.
- Using mousedown to distinguish internal clicks: this fired before
  selecting an item in the dropdown, so the dropdown closed too early
  and the item click was never applied.

Task: 5263792
@dhrp-odoo dhrp-odoo force-pushed the 17.0-tab-navigation-breaks-layout-dhrp branch from d7c7704 to 96be6b9 Compare November 28, 2025 05:31
@dhrp-odoo dhrp-odoo changed the base branch from 17.0 to 19.0 November 28, 2025 05:31
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)
robodoo r+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants