-
Notifications
You must be signed in to change notification settings - Fork 4
integrate: RCB scroll selection fix into PR #274 #276
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
Closed
masarray
wants to merge
2
commits into
fix/black-fascia-fat-progress-restore
from
fix/legacy-sas-rcb-selection-virtualization
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using System.Runtime.CompilerServices; | ||
| using System.Windows; | ||
| using System.Windows.Controls; | ||
| using System.Windows.Controls.Primitives; | ||
| using ArIED61850Tester.Models; | ||
|
|
||
| namespace ArIED61850Tester; | ||
|
|
||
| /// <summary> | ||
| /// Keeps the P1 multi-RCB selection model authoritative when the legacy DataGrid virtualizes | ||
| /// and recycles checkbox containers. A recycled CheckBox re-applies IsChecked from the bound | ||
| /// RcbExportRow.IsSelected value, which raises Checked/Unchecked even though the operator did | ||
| /// not change selection. The original single-select instance handlers interpret that visual | ||
| /// rehydration as a user action and call SelectOnly, silently clearing the other selected RCBs. | ||
| /// | ||
| /// P1 pointer/keyboard handling already owns real operator selection changes, so these routed | ||
| /// state-change events are presentation-only for this grid and must not reach the stale | ||
| /// single-select handlers. | ||
| /// </summary> | ||
| public partial class RcbExportFilterWindow | ||
| { | ||
| [ModuleInitializer] | ||
| internal static void RegisterLegacyRcbVirtualizedSelectionAuthority() | ||
| { | ||
| EventManager.RegisterClassHandler( | ||
| typeof(CheckBox), | ||
| ToggleButton.CheckedEvent, | ||
| new RoutedEventHandler(SuppressLegacyRcbSingleSelectStateHandler), | ||
| handledEventsToo: true); | ||
| EventManager.RegisterClassHandler( | ||
| typeof(CheckBox), | ||
| ToggleButton.UncheckedEvent, | ||
| new RoutedEventHandler(SuppressLegacyRcbSingleSelectStateHandler), | ||
| handledEventsToo: true); | ||
| } | ||
|
|
||
| private static void SuppressLegacyRcbSingleSelectStateHandler(object sender, RoutedEventArgs e) | ||
| { | ||
| if (sender is not CheckBox checkBox || | ||
| checkBox.DataContext is not RcbExportRow || | ||
| Window.GetWindow(checkBox) is not RcbExportFilterWindow window || | ||
| FindP1LegacyRcbAncestor<DataGrid>(checkBox) is not { } grid || | ||
| !ReferenceEquals(grid, window.RcbGrid)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Do not allow the original XAML Checked/Unchecked instance handlers to translate | ||
| // DataGrid container materialization/recycling into a single-selection mutation. | ||
| // RcbExportRow.IsSelected remains the durable selection authority. | ||
| e.Handled = true; | ||
| } | ||
| } | ||
81 changes: 81 additions & 0 deletions
81
tests/ARSAS.Tests/RcbSelectionVirtualizationRegressionTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| using ArIED61850Tester; | ||
| using ArIED61850Tester.Models; | ||
|
|
||
| namespace ARSAS.Tests; | ||
|
|
||
| public sealed class RcbSelectionVirtualizationRegressionTests | ||
| { | ||
| [Fact] | ||
| public void LegacyRcbGrid_RecycledCheckboxEventsCannotReachSingleSelectHandlers() | ||
| { | ||
| var xaml = Read("RcbExportFilterWindow.xaml"); | ||
| var authority = Read("RcbExportFilterWindow.VirtualizedSelectionAuthority.cs"); | ||
|
|
||
| Assert.Contains( | ||
| "IsChecked=\"{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}\"", | ||
| xaml, | ||
| StringComparison.Ordinal); | ||
|
|
||
| // These legacy handlers still exist for the original single-RCB window contract. The | ||
| // P1 multi-select authority must stop virtualization-generated Checked/Unchecked events | ||
| // before those instance handlers can translate visual rehydration into SelectOnly(). | ||
| Assert.Contains("Checked=\"RcbCheckBox_Checked\"", xaml, StringComparison.Ordinal); | ||
| Assert.Contains("Unchecked=\"RcbCheckBox_Unchecked\"", xaml, StringComparison.Ordinal); | ||
| Assert.Contains("ToggleButton.CheckedEvent", authority, StringComparison.Ordinal); | ||
| Assert.Contains("ToggleButton.UncheckedEvent", authority, StringComparison.Ordinal); | ||
| Assert.Contains("ReferenceEquals(grid, window.RcbGrid)", authority, StringComparison.Ordinal); | ||
| Assert.Contains("e.Handled = true", authority, StringComparison.Ordinal); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void MultiRcbSelectionAuthority_KeepsIndependentRowsSelected() | ||
| { | ||
| var rows = new List<RcbExportRow> | ||
| { | ||
| NewRow("Buffer"), | ||
| NewRow("Unbuffer"), | ||
| NewRow("A_URCB"), | ||
| NewRow("A_URCB_1"), | ||
| NewRow("A_URCB_10") | ||
| }; | ||
| var anchorIndex = -1; | ||
| var anchorValue = false; | ||
|
|
||
| for (var index = 0; index < 4; index++) | ||
| { | ||
| MainWindow.ApplyRcbSelectionForTest( | ||
| rows, | ||
| ref anchorIndex, | ||
| ref anchorValue, | ||
| index, | ||
| extendRange: false); | ||
| } | ||
|
|
||
| Assert.Equal(4, rows.Count(row => row.IsSelected)); | ||
| Assert.All(rows.Take(4), row => Assert.True(row.IsSelected)); | ||
| Assert.False(rows[4].IsSelected); | ||
| } | ||
|
|
||
| private static RcbExportRow NewRow(string name) | ||
| => new() | ||
| { | ||
| Name = name, | ||
| Reference = $"IED/LLN0.{name}", | ||
| SourceSelectionKey = name, | ||
| ExportName = name | ||
| }; | ||
|
|
||
| private static string Read(string relativePath) | ||
| { | ||
| DirectoryInfo? directory = new(AppContext.BaseDirectory); | ||
| while (directory != null) | ||
| { | ||
| var candidate = Path.Combine(directory.FullName, relativePath); | ||
| if (File.Exists(candidate)) | ||
| return File.ReadAllText(candidate); | ||
| directory = directory.Parent; | ||
| } | ||
|
|
||
| throw new FileNotFoundException(relativePath); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a checkbox is toggled through UI Automation (for example, a screen reader invoking
TogglePattern) rather than mouse or Space-key input, the two-way binding still changesRcbExportRow.IsSelected, but this handler now suppresses both legacy callbacks and the P1 preview handlers never run. ConsequentlySelectedRow, the footer summaries, andExportButton.IsEnabledremain stale—for example, unticking the only selected row leaves Export enabled and still reports that row as retained. Preserve a path that synchronizes the multi-selection UI for genuine toggles that do not pass through the preview handlers.Useful? React with 👍 / 👎.