From c8b54a50eb69da3aa7abbc11531b65bcd14a3e30 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Mon, 16 Sep 2024 21:33:21 +0100 Subject: [PATCH 01/14] Make QuickGrid's private CloseColumnOptions into public CloseColumnOptionsAsync --- .../src/QuickGrid.razor | 2 +- .../src/QuickGrid.razor.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor b/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor index f1fce0c434ce..92a21aca8748 100644 --- a/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor +++ b/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor @@ -10,7 +10,7 @@ @{ FinishCollectingColumns(); } - +
@_renderColumnHeaders diff --git a/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs b/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs index 3edf9b93c740..4c79ae184a6b 100644 --- a/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs +++ b/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs @@ -272,6 +272,16 @@ public Task ShowColumnOptionsAsync(ColumnBase column) return Task.CompletedTask; } + /// + /// Closes the UI that was previously displayed. + /// + public Task CloseColumnOptionsAsync() + { + _displayOptionsForColumn = null; + StateHasChanged(); + return Task.CompletedTask; + } + /// /// Instructs the grid to re-fetch and render the current data from the supplied data source /// (either or ). @@ -440,9 +450,4 @@ public async ValueTask DisposeAsync() // the client disconnected. This is not an error. } } - - private void CloseColumnOptions() - { - _displayOptionsForColumn = null; - } } From 03c381febdb8bcbcff8d3294f5e7bea0208e8ac4 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Mon, 16 Sep 2024 21:41:33 +0100 Subject: [PATCH 02/14] Update PublicAPI.Unshipped.txt --- .../src/PublicAPI.Unshipped.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt b/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt index df5bddfc6bfc..bd9dcc0e3a1e 100644 --- a/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt +++ b/src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt @@ -1,3 +1,4 @@ #nullable enable Microsoft.AspNetCore.Components.QuickGrid.QuickGrid.OverscanCount.get -> int Microsoft.AspNetCore.Components.QuickGrid.QuickGrid.OverscanCount.set -> void +Microsoft.AspNetCore.Components.QuickGrid.QuickGrid.CloseColumnOptionsAsync() -> System.Threading.Tasks.Task! From d4ad6deefca7839a6c51b0c63eb0a9a97d5453b8 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Mon, 16 Sep 2024 23:30:41 +0100 Subject: [PATCH 03/14] Add test --- .../test/E2ETest/Tests/QuickGridTest.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index a151e900e7c5..7502a604a05f 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -121,4 +121,31 @@ public void AdditionalAttributesApplied() Assert.Equal("somevalue", grid.GetAttribute("custom-attrib")); Assert.Contains("custom-class-attrib", grid.GetAttribute("class")?.Split(" ")); } + + [Fact] + public void CanOpenColumnOptions() + { + var grid = app.FindElement(By.CssSelector("#grid > table")); + var firstNameColumnOptionsButton = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(2) > div > button[title=\"Column options\"]")); + + firstNameColumnOptionsButton.Click(); + + var firstNameSearchSelector = "thead > tr > th:nth-child(2) input[type=search]"; + app.Exists(By.CssSelector(firstNameSearchSelector)); + } + + [Fact] + public void CanCloseColumnOptions() + { + var grid = app.FindElement(By.CssSelector("#grid > table")); + var firstNameColumnOptionsButton = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(2) > div > button[title=\"Column options\"]")); + + firstNameColumnOptionsButton.Click(); + + // Click outside the column options to close + grid.FindElement("tbody").Click(); + + var firstNameSearchSelector = "thead > tr > th:nth-child(2) input[type=search]"; + app.DoesNotExist(By.CssSelector(firstNameSearchSelector)); + } } From 971a7e406c5b190e4e4a64e98f6f8198bc711c0f Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Mon, 16 Sep 2024 23:38:52 +0100 Subject: [PATCH 04/14] Use Browser --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index 7502a604a05f..77e33be70c71 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -131,7 +131,7 @@ public void CanOpenColumnOptions() firstNameColumnOptionsButton.Click(); var firstNameSearchSelector = "thead > tr > th:nth-child(2) input[type=search]"; - app.Exists(By.CssSelector(firstNameSearchSelector)); + Browser.Exists(By.CssSelector(firstNameSearchSelector)); } [Fact] @@ -146,6 +146,6 @@ public void CanCloseColumnOptions() grid.FindElement("tbody").Click(); var firstNameSearchSelector = "thead > tr > th:nth-child(2) input[type=search]"; - app.DoesNotExist(By.CssSelector(firstNameSearchSelector)); + Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); } } From c669b2be42c20138a98ff05a2f6f7c56b31b3706 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Mon, 16 Sep 2024 23:40:47 +0100 Subject: [PATCH 05/14] Increase selector specificity --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index 77e33be70c71..f6c1eafb7f43 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -130,7 +130,7 @@ public void CanOpenColumnOptions() firstNameColumnOptionsButton.Click(); - var firstNameSearchSelector = "thead > tr > th:nth-child(2) input[type=search]"; + var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; Browser.Exists(By.CssSelector(firstNameSearchSelector)); } @@ -145,7 +145,7 @@ public void CanCloseColumnOptions() // Click outside the column options to close grid.FindElement("tbody").Click(); - var firstNameSearchSelector = "thead > tr > th:nth-child(2) input[type=search]"; + var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); } } From 87ff6bd38868995b4831f5c80f37172113d13a4e Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Mon, 16 Sep 2024 23:54:20 +0100 Subject: [PATCH 06/14] Use By.CssSelector --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index f6c1eafb7f43..8dbeda7c2aad 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -143,7 +143,7 @@ public void CanCloseColumnOptions() firstNameColumnOptionsButton.Click(); // Click outside the column options to close - grid.FindElement("tbody").Click(); + grid.FindElement(By.CssSelector("tbody")).Click(); var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); From 3a780c19e257c528378fd97dba1065b6f87970a1 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Tue, 17 Sep 2024 09:31:35 +0100 Subject: [PATCH 07/14] Click table --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index 8dbeda7c2aad..febfb3e9173f 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -143,7 +143,7 @@ public void CanCloseColumnOptions() firstNameColumnOptionsButton.Click(); // Click outside the column options to close - grid.FindElement(By.CssSelector("tbody")).Click(); + grid.FindElement(By.CssSelector("#grid")).Click(); var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); From 717bb55807acee75436cef8b461844a6a6527bcd Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Tue, 17 Sep 2024 20:18:30 +0100 Subject: [PATCH 08/14] Fix selector --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index febfb3e9173f..f68f0d73b232 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -143,7 +143,7 @@ public void CanCloseColumnOptions() firstNameColumnOptionsButton.Click(); // Click outside the column options to close - grid.FindElement(By.CssSelector("#grid")).Click(); + grid.Click(); var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); From ee90cb843add5ca2e45fc2752f852162d9337b23 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Tue, 17 Sep 2024 20:27:32 +0100 Subject: [PATCH 09/14] Add test --- .../test/E2ETest/Tests/QuickGridTest.cs | 17 ++++++++++++++++- .../SampleQuickGridComponent.razor | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index f68f0d73b232..f22dff12f33c 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -135,7 +135,7 @@ public void CanOpenColumnOptions() } [Fact] - public void CanCloseColumnOptions() + public void CanCloseColumnOptionsByBlurring() { var grid = app.FindElement(By.CssSelector("#grid > table")); var firstNameColumnOptionsButton = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(2) > div > button[title=\"Column options\"]")); @@ -148,4 +148,19 @@ public void CanCloseColumnOptions() var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); } + + [Fact] + public void CanCloseColumnOptionsByCloseColumnOptionsAsync() + { + var grid = app.FindElement(By.CssSelector("#grid > table")); + var firstNameColumnOptionsButton = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(2) > div > button[title=\"Column options\"]")); + + firstNameColumnOptionsButton.Click(); + + // Click the button inside the column options to close, this calls CloseColumnOptionsAsync + grid.FindElement(By.CssSelector("#close-column-options")).Click(); + + var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; + Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector)); + } } diff --git a/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor b/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor index ad76551bae3b..8eb11ea6f51d 100644 --- a/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor @@ -3,13 +3,14 @@

Sample QuickGrid Component

- + + @@ -23,6 +24,7 @@ record Person(int PersonId, string firstName, string lastName, DateOnly BirthDate); PaginationState pagination = new PaginationState { ItemsPerPage = 10 }; string firstNameFilter; + QuickGrid quickGrid; int ComputeAge(DateOnly birthDate) => DateTime.Now.Year - birthDate.Year - (birthDate.DayOfYear < DateTime.Now.DayOfYear ? 0 : 1); From c9770cbca9fcde39a1a5240bc544c2dd29ded19d Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Tue, 17 Sep 2024 23:08:39 +0100 Subject: [PATCH 10/14] Set button type --- .../BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor b/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor index 8eb11ea6f51d..4f941eee36c7 100644 --- a/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor @@ -10,7 +10,7 @@ - + From 7b3b8e76fea3e1749b92fbafb9d0eee83843bf31 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Tue, 17 Sep 2024 23:09:28 +0100 Subject: [PATCH 11/14] Change comment --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index f22dff12f33c..9782e403cd0c 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -157,7 +157,7 @@ public void CanCloseColumnOptionsByCloseColumnOptionsAsync() firstNameColumnOptionsButton.Click(); - // Click the button inside the column options to close, this calls CloseColumnOptionsAsync + // Click the button inside the column options to close, this calls QuickGrid.CloseColumnOptionsAsync grid.FindElement(By.CssSelector("#close-column-options")).Click(); var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; From 1b156e6dbcc95cc678c6bb83d0accde86d6995fe Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Tue, 17 Sep 2024 23:10:11 +0100 Subject: [PATCH 12/14] Rename ref --- .../QuickGridTest/SampleQuickGridComponent.razor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor b/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor index 4f941eee36c7..0d031faaddef 100644 --- a/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor @@ -3,14 +3,14 @@

Sample QuickGrid Component

- + - + @@ -24,7 +24,7 @@ record Person(int PersonId, string firstName, string lastName, DateOnly BirthDate); PaginationState pagination = new PaginationState { ItemsPerPage = 10 }; string firstNameFilter; - QuickGrid quickGrid; + QuickGrid quickGridRef; int ComputeAge(DateOnly birthDate) => DateTime.Now.Year - birthDate.Year - (birthDate.DayOfYear < DateTime.Now.DayOfYear ? 0 : 1); From 9adb799374dcb30a1c8a3ea9b643a3f835f031b8 Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Wed, 18 Sep 2024 12:37:54 +0100 Subject: [PATCH 13/14] Change comment to rebuild --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index 9782e403cd0c..40d8f9d4b272 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -157,7 +157,7 @@ public void CanCloseColumnOptionsByCloseColumnOptionsAsync() firstNameColumnOptionsButton.Click(); - // Click the button inside the column options to close, this calls QuickGrid.CloseColumnOptionsAsync + // Click the button inside the column options popup to close, this calls QuickGrid.CloseColumnOptionsAsync grid.FindElement(By.CssSelector("#close-column-options")).Click(); var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]"; From 653a185d271b5a588ba43c215bf5dccf77eaea4c Mon Sep 17 00:00:00 2001 From: Matt Hetherington Date: Fri, 20 Sep 2024 21:31:35 +0100 Subject: [PATCH 14/14] Change comment to rebuild --- src/Components/test/E2ETest/Tests/QuickGridTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/QuickGridTest.cs b/src/Components/test/E2ETest/Tests/QuickGridTest.cs index 40d8f9d4b272..c27021a5025a 100644 --- a/src/Components/test/E2ETest/Tests/QuickGridTest.cs +++ b/src/Components/test/E2ETest/Tests/QuickGridTest.cs @@ -157,7 +157,7 @@ public void CanCloseColumnOptionsByCloseColumnOptionsAsync() firstNameColumnOptionsButton.Click(); - // Click the button inside the column options popup to close, this calls QuickGrid.CloseColumnOptionsAsync + // Click the button inside the column options popup to close, which calls QuickGrid.CloseColumnOptionsAsync grid.FindElement(By.CssSelector("#close-column-options")).Click(); var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]";