Skip to content

Commit 39a29b6

Browse files
author
antoineatrhea
committed
Missing scroll inside RequirementBreakdown when focusing
1 parent e710d31 commit 39a29b6

6 files changed

Lines changed: 59 additions & 5 deletions

File tree

UI_DSM.Client/Components/App/CommentCard/CommentCard.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<AppAccordion Label="Linked Items" Variant="AppAccordion.VariantValue.Reply" @bind-PanelOpen="@this.IsPanelOpen">
106106
@foreach (var linkedItem in this.ViewModel.LinkedRows.DistinctBy(x => x.Id).OrderBy(x => x.Id))
107107
{
108-
<button @ondblclick="() => this.OnDoubleClick(linkedItem.Id)">@linkedItem.Id</button>
108+
<button class="app-comment__linked" @ondblclick="() => this.OnDoubleClick(linkedItem.Id)">@linkedItem.Id</button>
109109
}
110110
</AppAccordion>
111111
</div>

UI_DSM.Client/Components/App/CommentCard/CommentCard.razor.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@
5959
.app-comment__replies {
6060
padding-top: var(--spacing-2);
6161
border-top: 1px solid var(--colors-gray-50)
62+
}
63+
64+
.app-comment__linked {
65+
margin-right: 5px;
6266
}

UI_DSM.Client/Components/NormalUser/Views/RequirementBreakdownStructureView.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<CellDisplayTemplate>
4747
@if (context.DataItem is RequirementRowViewModel row)
4848
{
49+
<span id="row_@row.ThingId"></span>
4950
<HaveThingRowIcons Row="row"/>
5051
}
5152
</CellDisplayTemplate>

UI_DSM.Client/Components/NormalUser/Views/RequirementBreakdownStructureView.razor.cs

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ namespace UI_DSM.Client.Components.NormalUser.Views
1919

2020
using DevExpress.Blazor;
2121

22+
using Microsoft.AspNetCore.Components;
23+
using Microsoft.JSInterop;
24+
2225
using ReactiveUI;
2326

2427
using UI_DSM.Client.ViewModels.Components.NormalUser.Views;
@@ -35,11 +38,22 @@ public partial class RequirementBreakdownStructureView : GenericBaseView<IRequir
3538
/// </summary>
3639
private readonly List<IDisposable> disposables = new();
3740

41+
/// <summary>
42+
/// Id of the element where the view should scroll to
43+
/// </summary>
44+
private Guid idToScrollTo;
45+
3846
/// <summary>
3947
/// The <see cref="DxGrid" />
4048
/// </summary>
4149
protected DxGrid DxGrid { get; set; }
4250

51+
/// <summary>
52+
/// The <see cref="IJSRuntime" />
53+
/// </summary>
54+
[Inject]
55+
public IJSRuntime JsRuntime { get; set; }
56+
4357
/// <summary>
4458
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
4559
/// </summary>
@@ -70,11 +84,16 @@ public async Task<bool> CopyComponents(BaseView otherView)
7084
/// </summary>
7185
/// <param name="itemName">The name of the item to navigate to</param>
7286
/// <returns>A <see cref="Task" /></returns>
73-
public override Task TryNavigateToItem(string itemName)
87+
public override async Task TryNavigateToItem(string itemName)
7488
{
7589
var item = this.ViewModel.Rows.FirstOrDefault(x => string.Equals(itemName, x.Id, StringComparison.InvariantCultureIgnoreCase));
7690

77-
return item != null ? this.DxGrid.SetFocusedDataItemAsync(item) : Task.CompletedTask;
91+
if (item != null)
92+
{
93+
await this.DxGrid.SetFocusedDataItemAsync(item);
94+
this.idToScrollTo = item.ThingId;
95+
await this.HasChanged();
96+
}
7897
}
7998

8099
/// <summary>
@@ -86,7 +105,7 @@ public override Task TryNavigateToItem(string itemName)
86105
/// <param name="reviewTaskId">The <see cref="ReviewTask" /> id</param>
87106
/// <param name="prefilters">A collection of prefilters</param>
88107
/// <param name="additionnalColumnsVisibleAtStart">A collection of columns name that can be visible by default at start</param>
89-
/// <param name="participant">The current <see cref="Participant"/></param>
108+
/// <param name="participant">The current <see cref="Participant" /></param>
90109
/// <returns>A <see cref="Task" /></returns>
91110
public override async Task InitializeViewModel(IEnumerable<Thing> things, Guid projectId, Guid reviewId, Guid reviewTaskId, List<string> prefilters, List<string> additionnalColumnsVisibleAtStart, Participant participant)
92111
{
@@ -116,6 +135,35 @@ protected void OnClick()
116135
this.DxGrid.ShowColumnChooser("#column-chooser");
117136
}
118137

138+
/// <summary>
139+
/// Method invoked after each time the component has been rendered. Note that the component does
140+
/// not automatically re-render after the completion of any returned <see cref="T:System.Threading.Tasks.Task" />, because
141+
/// that would cause an infinite render loop.
142+
/// </summary>
143+
/// <param name="firstRender">
144+
/// Set to <c>true</c> if this is the first time
145+
/// <see cref="M:Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(System.Boolean)" /> has been invoked
146+
/// on this component instance; otherwise <c>false</c>.
147+
/// </param>
148+
/// <returns>A <see cref="T:System.Threading.Tasks.Task" /> representing any asynchronous operation.</returns>
149+
/// <remarks>
150+
/// The <see cref="M:Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(System.Boolean)" /> and
151+
/// <see cref="M:Microsoft.AspNetCore.Components.ComponentBase.OnAfterRenderAsync(System.Boolean)" /> lifecycle methods
152+
/// are useful for performing interop, or interacting with values received from <c>@ref</c>.
153+
/// Use the <paramref name="firstRender" /> parameter to ensure that initialization work is only performed
154+
/// once.
155+
/// </remarks>
156+
protected override async Task OnAfterRenderAsync(bool firstRender)
157+
{
158+
await base.OnAfterRenderAsync(firstRender);
159+
160+
if (this.idToScrollTo != Guid.Empty)
161+
{
162+
await this.JsRuntime.InvokeVoidAsync("scrollToElement", $"row_{this.idToScrollTo}", "center", "center");
163+
this.idToScrollTo = Guid.Empty;
164+
}
165+
}
166+
119167
/// <summary>
120168
/// Apply the filtering on rows
121169
/// </summary>

UI_DSM.Client/Components/NormalUser/Views/RequirementVerificationControlView.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<CellDisplayTemplate>
4646
@if (context.DataItem is RequirementRowViewModel row)
4747
{
48+
<span id="row_@row.ThingId"></span>
4849
<HaveThingRowIcons Row="row"/>
4950
}
5051
</CellDisplayTemplate>

UI_DSM.Client/UI_DSM.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net6.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
5-
<AssemblyVersion>1.6.3</AssemblyVersion>
5+
<AssemblyVersion>1.6.4</AssemblyVersion>
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="Blazored.SessionStorage" Version="2.2.0" />

0 commit comments

Comments
 (0)