Skip to content
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

Navigator shows wrong context menu entries when the application is started with open file(s) #12937

Closed
meisenbarth-work opened this issue Sep 25, 2023 · 2 comments · Fixed by #13710
Assignees

Comments

@meisenbarth-work
Copy link

Bug Description:

When an editor is already open (and thus restored) when Theia is started and you perform a right click in the file that belongs to that editor the context menu is almost empty, all entries that are file specific are missing. When you switch the editor or select a different file it works afterwards.

Steps to Reproduce:

  1. Open a file (I used Blueprint to ensure it is not a issue in my application)
  2. Click in the Navigator to give it focus
  3. Reload the window
  4. Open the context menu for the already preselected file in the navigator widget

Additional Information

  • Operating System: Windows 10, Chrome
  • Theia Version: 1.41.0 (Current Blueprint)

Debugging showed SelectionService.selection is not set.

@meisenbarth-work
Copy link
Author

I did some more tests and the problem can be triggered more easily when Explorer: Auto Reveal is disabled.
The problem is, the URI passed to the event handler (UriAwareCommandHandler) is for the last active editor when the context menu for the currently selected node in the navigation widget is opened and not for the node. It looks like SelectionService.selection is not updated, since the node is already selected.

Why does the event handler use SelectionService.selection and not the uri from the node?

@meisenbarth-work
Copy link
Author

meisenbarth-work commented Oct 12, 2023

As workaround I've now extended and rebound FileNavigatorWidget with:

protected override onAfterAttach(msg: Message): void {
    super.onAfterAttach(msg);
    this.addEventListener(this.node, 'focus', () => {
        if (this.props.globalSelection) {
            this.updateGlobalSelection();
        }
    }, true);
}

It looks like it works, but I am not sure that is the proper solution, maybe someone else could look into it?

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 a pull request may close this issue.

2 participants