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

Activate new current tab #7349

Merged
merged 3 commits into from
Dec 12, 2019

Conversation

mbektas
Copy link
Member

@mbektas mbektas commented Oct 13, 2019

fixes #6648

This fixes the issue when current tab and active widget mismatch after closing a tab using keyboard shortcut [Alt W]. It is done by explicitly activating new current tab.

@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@jasongrout
Copy link
Contributor

jasongrout commented Oct 14, 2019

From #6648

@jasongrout I have been debugging this. I couldn't find a case when a tab is closed while keeping focus somewhere else. For example, if you close the tab using command palette (Close Tab item), palette resets and releases focus to newly activated tab. So, I found it safe to just activate new current tab as a solution.

Just because that's the way it's done in core currently, I don't think we should necessarily force it on users and extensions.

Is there a way to implement @sccolbert's suggestion of (a) checking if we are doing a close event, not just any change event, and (b) checking if the closed tab had focus?

@jasongrout
Copy link
Contributor

For example, we could install a child-removed message interceptor somewhere that catches the widget actually removing itself. Or maybe using the activeChanged signal might help, since that also implies something about current focus.

@mbektas
Copy link
Member Author

mbektas commented Oct 15, 2019

@jasongrout whenever a tab is closed, it is removed from focustracker and it explicitly sets the active widget to null (https://github.com/phosphorjs/phosphor/blob/master/packages/widgets/src/focustracker.ts#L252).

How about if we add a check if activeWidget is null when current is changed, before setting the new current to new active? It seems to work properly.

app.shell.currentChanged.connect((sender, args) => {
      if (!app.shell.activeWidget && args.newValue) {
        app.shell.activateById(args.newValue.id);
      }
});

implementing @sccolbert's suggestion should be also possible but definitely more complex.

@jasongrout
Copy link
Contributor

whenever a tab is closed, it is removed from focustracker and it explicitly sets the active widget to null

More than that, it changes the current widget too. The active widget is set to null in other places too, but in those situations, the current widget is kept the same.

Yes, I think that logic might work well to identify widgets being removed. Let's try it out.

@jasongrout jasongrout added this to the 2.0 milestone Oct 15, 2019
@mbektas
Copy link
Member Author

mbektas commented Oct 15, 2019

Yes, I think that logic might work well to identify widgets being removed. Let's try it out.

I pushed the change.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me (I tried it locally). Thanks!

@blink1073 blink1073 merged commit 8d773bf into jupyterlab:master Dec 12, 2019
@blink1073 blink1073 mentioned this pull request Dec 23, 2019
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Jan 12, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg:application status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't do repeated closing of tabs using kb
3 participants