diff --git a/COMETwebapp/Components/Tabs/TabsPanelComponent.razor b/COMETwebapp/Components/Tabs/TabsPanelComponent.razor index ffc055a9..db892788 100644 --- a/COMETwebapp/Components/Tabs/TabsPanelComponent.razor +++ b/COMETwebapp/Components/Tabs/TabsPanelComponent.razor @@ -26,32 +26,32 @@
@if (this.Handler.CurrentTab is not null) { -
- - @foreach (var tab in this.Tabs) - { - - } - - +
+
+ @foreach (var tab in this.Tabs) + { + + } + +
@if (this.IsSidePanelAvailable) { + CssClass="ml-auto p-0"> diff --git a/COMETwebapp/Components/Tabs/TabsPanelComponent.razor.cs b/COMETwebapp/Components/Tabs/TabsPanelComponent.razor.cs index b81b4d0e..56022b4a 100644 --- a/COMETwebapp/Components/Tabs/TabsPanelComponent.razor.cs +++ b/COMETwebapp/Components/Tabs/TabsPanelComponent.razor.cs @@ -162,7 +162,7 @@ private void AddSidePanel() currentTab.Panel = newPanel; this.ViewModel.SidePanels.Add(newPanel); - this.ViewModel.CurrentTab = this.ViewModel.OpenTabs.Items.LastOrDefault(x => x.ComponentType == this.ViewModel.SelectedApplication.ComponentType && x.Panel == null); + this.ViewModel.CurrentTab = this.ViewModel.OpenTabs.Items.FirstOrDefault(x => x.Panel == null); } } } diff --git a/COMETwebapp/Pages/Tabs.razor b/COMETwebapp/Pages/Tabs.razor index 3d029b73..85e40a22 100644 --- a/COMETwebapp/Pages/Tabs.razor +++ b/COMETwebapp/Pages/Tabs.razor @@ -33,17 +33,17 @@ OnCreateTabForModel="@(tab => this.OnCreateTabForModel(tab))" OnRemoveTabClick="@(tab => this.OnRemoveTabClick(tab))" OnOpenTabClick="@(() => this.OnOpenTabClick())" - Tabs="@(this.OpenTabsFromSelectedApplication.Where(x => x.Panel == null).ToList())" + Tabs="@(this.OpenTabs.Where(x => x.Panel == null).ToList())" IsSidePanelAvailable="true"/> - @foreach (var panelsGrouping in this.OpenTabsFromSelectedApplication.Where(x => x.Panel is not null).GroupBy(x => x.Panel)) + @foreach (var panelsGrouping in this.OpenTabs.Where(x => x.Panel is not null).GroupBy(x => x.Panel)) { } } diff --git a/COMETwebapp/Pages/Tabs.razor.cs b/COMETwebapp/Pages/Tabs.razor.cs index feb2419c..22eec333 100644 --- a/COMETwebapp/Pages/Tabs.razor.cs +++ b/COMETwebapp/Pages/Tabs.razor.cs @@ -49,9 +49,9 @@ public partial class Tabs private TabPanelInformation SelectedSidePanel { get; set; } /// - /// Collection of open tabs that belong from the selected application + /// Collection of open tabs that belong from view model sourcelist /// - private IEnumerable OpenTabsFromSelectedApplication => this.ViewModel.OpenTabs.Items.Where(x => x.ComponentType == this.ViewModel.SelectedApplication?.ComponentType); + private IEnumerable OpenTabs => this.ViewModel.OpenTabs.Items; /// /// The model id to fill the opentab form, if needed diff --git a/COMETwebapp/Shared/SideBarEntry/ApplicationsSideBar.razor.cs b/COMETwebapp/Shared/SideBarEntry/ApplicationsSideBar.razor.cs index 070f181b..ec726cb6 100644 --- a/COMETwebapp/Shared/SideBarEntry/ApplicationsSideBar.razor.cs +++ b/COMETwebapp/Shared/SideBarEntry/ApplicationsSideBar.razor.cs @@ -80,7 +80,11 @@ protected override void OnInitialized() { base.OnInitialized(); this.NavigationManager.LocationChanged += this.OnLocationChanged; - this.Disposables.Add(this.WhenAnyValue(x => x.TabsViewModel.SelectedApplication).SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); + + this.Disposables.Add(this.WhenAnyValue(x => + x.TabsViewModel.SelectedApplication, + x => x.TabsViewModel.CurrentTab + ).SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); } /// diff --git a/COMETwebapp/ViewModels/Pages/TabsViewModel.cs b/COMETwebapp/ViewModels/Pages/TabsViewModel.cs index 99b94f68..32db31b1 100644 --- a/COMETwebapp/ViewModels/Pages/TabsViewModel.cs +++ b/COMETwebapp/ViewModels/Pages/TabsViewModel.cs @@ -71,7 +71,7 @@ public TabsViewModel(ISessionService sessionService, IServiceProvider servicePro this.sessionService = sessionService; this.serviceProvider = serviceProvider; this.Disposables.Add(this.WhenAnyValue(x => x.SelectedApplication).Subscribe(_ => this.OnSelectedApplicationChange())); - this.Disposables.Add(this.WhenAnyValue(x => x.CurrentTab).Subscribe(_ => this.OnSelectedApplicationChange())); + this.Disposables.Add(this.WhenAnyValue(x => x.CurrentTab).Subscribe(_ => this.OnCurrentTabChange())); this.Disposables.Add(this.sessionService.OpenIterations.CountChanged.Subscribe(this.CloseTabIfIterationClosed)); this.Disposables.Add(this.OpenTabs.Connect().WhereReasonsAre(ListChangeReason.Remove, ListChangeReason.RemoveRange).Subscribe(this.OnOpenTabRemoved)); } @@ -163,7 +163,7 @@ public void CreateNewTab(TabbedApplication application, Guid objectOfInterestId, /// private void OnSelectedApplicationChange() { - if (this.SelectedApplication == null) + if (this.SelectedApplication == null || this.CurrentTab?.ComponentType == this.SelectedApplication?.ComponentType) { return; } @@ -181,7 +181,7 @@ private void OnCurrentTabChange() return; } - this.SelectedApplication = Applications.ExistingApplications.OfType().First(x => x.ComponentType == this.CurrentTab.ComponentType); + this.SelectedApplication = Applications.ExistingApplications.OfType().FirstOrDefault(x => x.ComponentType == this.CurrentTab.ComponentType); } /// @@ -250,7 +250,7 @@ private void SetCurrentTabAfterTabRemoval(IChangeSet x.ComponentType == this.SelectedApplication.ComponentType && x.Panel == selectedSidePanel); + handler.CurrentTab = this.OpenTabs.Items.FirstOrDefault(x => x.Panel == selectedSidePanel); } if (selectedSidePanel != null && handler.CurrentTab == null)