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

Add Close... option to Tab context menu #7728

Merged
merged 4 commits into from
Oct 15, 2020

Conversation

mpela81
Copy link
Contributor

@mpela81 mpela81 commented Sep 24, 2020

Summary of the Pull Request

Add a "Close..." option to the tab context menu, with nested entries to close tabs to the right and close other tabs (actions already available)
immagine

References

#1912

PR Checklist

  • Closes Feature request: close tabs to the right #5524
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

First contribution 🙂
Tried to follow some suggestions from #1912 (comment)

Validation Steps Performed

@ghost ghost added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Sep 24, 2020
@skyline75489
Copy link
Collaborator

Hi! Thanks for your contribution! The engineer who knows the most about this (@zadjii-msft ) is currently on paternity leave. And with the ongoing pandemic and everybody working from home, the team is just even more short-handed. Just want to let you know the feedback from the team may be slow. But I'm sure they will be more than willing to review your PR when they are available.

Why do I use they, you ask? Well I'm not part of the internal engineering team. I'm just a MS employee who wrote some code for this project. Feel free to contact me. Thanks again 😃

@mpela81
Copy link
Contributor Author

mpela81 commented Sep 30, 2020

@skyline75489, thanks for your comment, needless to say the team can review this at their convenience.

Well, by the way, I may need some expert hand as I'm getting random crashes 😞
I don't have exact repro steps (play with tabs and their menus for a while). The call stack is all about external code, no clue at the moment on how to debug it 🤔

Windows.UI.Xaml.dll!GetProgrammaticHitTestingParams(CCoreServices * coreServices, CUIElement * uiElement, ITransformer * * transformer, CUIElement * * ppThisNoRef, CPopupRoot * * popupRootNoRef, CUIElement * * popupHitTestSubtreeRootNoRef, bool * isRootNull) Line 5395    C++
    Windows.UI.Xaml.dll!UIElement_HitTestPoint(CUIElement * uiElement, CCoreServices * coreServices, XPOINTF ptHit, bool canHitDisabledElements, bool canHitInvisibleElements, int * pnCount, CUIElement * * * ppElements) Line 5513    C++
    Windows.UI.Xaml.dll!DirectUI::VisualTreeHelper::FindElementsInHostCoordinatesPointStatic(Windows::Foundation::Point intersectingPoint, Windows::UI::Xaml::IUIElement * pSubTree, unsigned char ppElements, unsigned char) Line 250  C++
    Windows.UI.Xaml.dll!DirectUI::VisualTreeHelper::FindAllElementsInHostCoordinatesPointStatic(Windows::Foundation::Point intersectingPoint, Windows::UI::Xaml::IUIElement * pSubTree, unsigned char includeAllElements, Windows::Foundation::Collections::IIterable<Windows::UI::Xaml::UIElement *> * * ppElements) Line 329  C++
    Windows.UI.Xaml.dll!DirectUI::CascadingMenuHelper::OnPointerExited(Windows::UI::Xaml::Input::IPointerRoutedEventArgs * args, bool parentIsSubMenu) Line 284 C++
    Windows.UI.Xaml.dll!DirectUI::MenuFlyoutSubItem::OnPointerExited(Windows::UI::Xaml::Input::IPointerRoutedEventArgs * args) Line 140 C++
    Windows.UI.Xaml.dll!DirectUI::ControlGenerated::OnPointerExitedProtected(Windows::UI::Xaml::Input::IPointerRoutedEventArgs * pE) Line 1404  C++
    Windows.UI.Xaml.dll!DirectUI::Control::FireEvent(KnownEventIndex nDelegate, DirectUI::DependencyObject * pSender, IInspectable * pArgs) Line 267    C++
...

Edit: also occurs with one tab only, just open/close the menu a few times in a row.

Thanks again!

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

This is awesome, thanks for doing this!

@zadjii-msft
Copy link
Member

As far as the crash is concerned - I'm not seeing that locally when playing around with this. I vaguely recall seeing a similar crash when debugging a MenuFlyout like, maybe 14 months ago, but the crash ended up being a transient thing, or was related to XAML debugging or something. I think this is probably safe to go in now, and we can keep an eye on it

@zadjii-msft zadjii-msft removed their assignment Oct 7, 2020
@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Oct 7, 2020
@mpela81
Copy link
Contributor Author

mpela81 commented Oct 7, 2020

Noticed that master branch has progressed in the meantime, I guess PR will require some change because of the new TerminalSettingsModel #7667

Copy link
Contributor

@leonMSFT leonMSFT left a comment

Choose a reason for hiding this comment

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

This is great, I love the detail of disabling the menu items if it doesn't apply to that tab! 😄

@mpela81
Copy link
Contributor Author

mpela81 commented Oct 13, 2020

Ah thanks for your reviews so far 🤞

@zadjii-msft
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 15, 2020
@ghost
Copy link

ghost commented Oct 15, 2020

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@zadjii-msft
Copy link
Member

This is bizarre, Github can't seem to forget about this one failed CI build from a week ago, despite re-running the CI successfully since then. I think we're going to have to merge this one manually with an override - the CI failure was definitely unrelated to this PR, and the CI has subsequently passed...

@zadjii-msft zadjii-msft merged commit 004da88 into microsoft:master Oct 15, 2020
@mpela81 mpela81 deleted the feat/tab_close_submenu branch October 15, 2020 12:32
ghost pushed a commit that referenced this pull request Oct 19, 2020
Fix for crash occurring when splitting a pane, due to tab context menu created multiple times.

## References
#7728 

## PR Checklist
* [x] Closes #7941 
* [x] CLA signed. 

## Detailed Description of the Pull Request / Additional comments
When splitting panes the `Tab::Initialize` function is called again. This rebuilt the context menu from scratch and appended the existing Close... sub-menu items to a new parent, thus causing the crash.
It is not necessary to re-create the context menu every time you split panes, it can be created only once.

## Validation Steps Performed
Manual verification:
- Play with the context menu, the Close... submenu is functioning
- Split panes (ALT + New tab), no crash occurs and context menu still functioning
ghost pushed a commit that referenced this pull request Oct 29, 2020
`TerminalTab` and `SettingsTab` share some implementation details. The
close submenu introduced in #7728 is a good example of functionality
that is consistent across all tabs. This PR transforms `ITab` from an
interface, into an [unsealed runtime class] to de-duplicate some
functionality. Most of the logic from `SettingsTab` was moved there
because I expect the default behavior of a tab to resemble the
`SettingsTab` over a `TerminalTab`.

## References
Verified that Close submenu work was transferred over (#7728, #7961, #8010).

## Validation Steps Performed
Check close submenu on first/last tab when multiple tabs are open.

Closes #7969

[unsealed runtime class]: https://docs.microsoft.com/en-us/uwp/midl-3/intro#base-classes
DHowett pushed a commit that referenced this pull request Nov 3, 2020
In preparation for the Settings UI, we needed to make some changes to
Tab to abstract out shared, common functionality between different types
of tab. This is the result of that work. All code references to the
settings have been removed or reverted.

Contains changes from #8053, #7802.

The messages below only make sense in the context of the Settings UI,
which this pull request does not bring in. They do, however, provide
valuable information.

From #7802 (@leonMSFT):

> This PR's goal was to add an option to the `OpenSettings` keybinding to
> open the Settings UI in a tab. In order to implement that, a couple of
> changes had to be made to `Tab`, specifically:
>
> - Introduce a tab interface named `ITab`
> - Create/Rename two new Tab classes that implement `ITab` called
>   `SettingsTab` and `TerminalTab`
>

From #8053:

> `TerminalTab` and `SettingsTab` share some implementation details. The
> close submenu introduced in #7728 is a good example of functionality
> that is consistent across all tabs. This PR transforms `ITab` from an
> interface, into an [unsealed runtime class] to de-duplicate some
> functionality. Most of the logic from `SettingsTab` was moved there
> because I expect the default behavior of a tab to resemble the
> `SettingsTab` over a `TerminalTab`.
>
> ## References
> Verified that Close submenu work was transferred over (#7728, #7961, #8010).
>
> ## Validation Steps Performed
> Check close submenu on first/last tab when multiple tabs are open.
>
> Closes #7969
>
> [unsealed runtime class]: https://docs.microsoft.com/en-us/uwp/midl-3/intro#base-classes

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
DHowett pushed a commit that referenced this pull request Nov 3, 2020
In preparation for the Settings UI, we needed to make some changes to
Tab to abstract out shared, common functionality between different types
of tab. This is the result of that work. All code references to the
settings have been removed or reverted.

Contains changes from #8053, #7802.

The messages below only make sense in the context of the Settings UI,
which this pull request does not bring in. They do, however, provide
valuable information.

From #7802 (@leonMSFT):

> This PR's goal was to add an option to the `OpenSettings` keybinding to
> open the Settings UI in a tab. In order to implement that, a couple of
> changes had to be made to `Tab`, specifically:
>
> - Introduce a tab interface named `ITab`
> - Create/Rename two new Tab classes that implement `ITab` called
>   `SettingsTab` and `TerminalTab`
>

From #8053:

> `TerminalTab` and `SettingsTab` share some implementation details. The
> close submenu introduced in #7728 is a good example of functionality
> that is consistent across all tabs. This PR transforms `ITab` from an
> interface, into an [unsealed runtime class] to de-duplicate some
> functionality. Most of the logic from `SettingsTab` was moved there
> because I expect the default behavior of a tab to resemble the
> `SettingsTab` over a `TerminalTab`.
>
> ## References
> Verified that Close submenu work was transferred over (#7728, #7961, #8010).
>
> ## Validation Steps Performed
> Check close submenu on first/last tab when multiple tabs are open.
>
> Closes #7969
>
> [unsealed runtime class]: https://docs.microsoft.com/en-us/uwp/midl-3/intro#base-classes

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
DHowett pushed a commit that referenced this pull request Nov 3, 2020
In preparation for the Settings UI, we needed to make some changes to
Tab to abstract out shared, common functionality between different types
of tab. This is the result of that work. All code references to the
settings have been removed or reverted.

Contains changes from #8053, #7802.

The messages below only make sense in the context of the Settings UI,
which this pull request does not bring in. They do, however, provide
valuable information.

From #7802 (@leonMSFT):

> This PR's goal was to add an option to the `OpenSettings` keybinding to
> open the Settings UI in a tab. In order to implement that, a couple of
> changes had to be made to `Tab`, specifically:
>
> - Introduce a tab interface named `ITab`
> - Create/Rename two new Tab classes that implement `ITab` called
>   `SettingsTab` and `TerminalTab`
>

From #8053:

> `TerminalTab` and `SettingsTab` share some implementation details. The
> close submenu introduced in #7728 is a good example of functionality
> that is consistent across all tabs. This PR transforms `ITab` from an
> interface, into an [unsealed runtime class] to de-duplicate some
> functionality. Most of the logic from `SettingsTab` was moved there
> because I expect the default behavior of a tab to resemble the
> `SettingsTab` over a `TerminalTab`.
>
> ## References
> Verified that Close submenu work was transferred over (#7728, #7961, #8010).
>
> ## Validation Steps Performed
> Check close submenu on first/last tab when multiple tabs are open.
>
> Closes #7969
>
> [unsealed runtime class]: https://docs.microsoft.com/en-us/uwp/midl-3/intro#base-classes

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
DHowett added a commit that referenced this pull request Nov 4, 2020
In preparation for the Settings UI, we needed to make some changes to
Tab to abstract out shared, common functionality between different types
of tab. This is the result of that work. All code references to the
settings have been removed or reverted.

Contains changes from #8053, #7802.

The messages below only make sense in the context of the Settings UI,
which this pull request does not bring in. They do, however, provide
valuable information.

From #7802 (@leonMSFT):

> This PR's goal was to add an option to the `OpenSettings` keybinding to
> open the Settings UI in a tab. In order to implement that, a couple of
> changes had to be made to `Tab`, specifically:
>
> - Introduce a tab interface named `ITab`
> - Create/Rename two new Tab classes that implement `ITab` called
>   `SettingsTab` and `TerminalTab`
>

From #8053:

> `TerminalTab` and `SettingsTab` share some implementation details. The
> close submenu introduced in #7728 is a good example of functionality
> that is consistent across all tabs. This PR transforms `ITab` from an
> interface, into an [unsealed runtime class] to de-duplicate some
> functionality. Most of the logic from `SettingsTab` was moved there
> because I expect the default behavior of a tab to resemble the
> `SettingsTab` over a `TerminalTab`.
>
> ## References
> Verified that Close submenu work was transferred over (#7728, #7961, #8010).
>
> ## Validation Steps Performed
> Check close submenu on first/last tab when multiple tabs are open.
>
> Closes #7969
>
> [unsealed runtime class]: https://docs.microsoft.com/en-us/uwp/midl-3/intro#base-classes

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>

Co-authored-by: Leon Liang <lelian@microsoft.com>
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.0 has been released which incorporates this pull request.:tada:

Handy links:

DHowett pushed a commit that referenced this pull request Apr 28, 2023
A resurrection of the original nested "Close" menu from #7728. We
discovered that nested flyouts crash in #8238. Those are fixed now
though! So we can bring this back.

This also includes the "Close Pane" item from #15198.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: close tabs to the right
4 participants