jupyterlab / lumino

Lumino is a library for building interactive web applications
https://lumino.readthedocs.io/
Other
598 stars 127 forks source link

Focus tracker does not focus on tab item #604

Closed brichet closed 11 months ago

brichet commented 1 year ago

Description

Some context menu in Jupyterlab are not working correctly since https://github.com/jupyterlab/lumino/pull/583.

It seems that the focus is not managed the same way when the tabs contain tabindex="0" attribute.

Reproduce

Update lumino to v2023.6.22 and right click on a Notebook tab in dock panel.

EXPECTED ACTUAL

The currentwidget seems to be now the tabbar instead of the tab item, which breaks the behavior of the context menu.

Expected behavior

The focus correctly handling the tab item.

Reference

This bug has been found in https://github.com/jupyterlab/jupyterlab/pull/14610

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

brichet commented 12 months ago

Some more context after a little introspection:

Adding the tabindex attribute to tabs allows them to get focus (that's the point). In Jupyterlab, the focusTracker tracks every element added to the shell, including the TabBar. Since tabs never get focus, the TabBar could not be the current widget of the focusTracker.

Right-clicking on a selected tab should bring up the context menu for the widget displayed (the open document in the case of mainArea). This uses the focusTracker.current widget to choose whether or not to display certain options. Now that the TabBar can receive focus, it becomes the current widget when a tab is right-clicked, which change the behavior of the context menu.