diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eb2ea685..41cf4c510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [62.0.1] +- [BottomSheet] Fixed crash when bottom bar buttons already have consumer-provided `AutomationId` values. + ## [62.0.0] - [StepFlow] **BREAKING**: Removed `StepFlowItem.LockWhenCompleted`. Use `StepFlowItem.CanGoBack` to allow selected completed steps to be reopened before the flow is fully completed, while resetting that step and following steps for confirmation again. - [BarcodeScanner] Fixed invalid scan-rectangle validation results restarting detection before the overlay returned to idle by waiting for the reset animation and adding a short cooldown before rescanning. diff --git a/src/library/DIPS.Mobile.UI/Components/BottomSheets/BottomSheet.cs b/src/library/DIPS.Mobile.UI/Components/BottomSheets/BottomSheet.cs index 2e707a81c..3d9ec145b 100644 --- a/src/library/DIPS.Mobile.UI/Components/BottomSheets/BottomSheet.cs +++ b/src/library/DIPS.Mobile.UI/Components/BottomSheets/BottomSheet.cs @@ -109,7 +109,10 @@ public Grid CreateBottomBar() grid.AddColumnDefinition(new ColumnDefinition(GridLength.Star)); var index = grid.ColumnDefinitions.Count - 1; grid.Add(button, index); - button.AutomationId = $"BottomBarButton{index}".ToDUIAutomationId(); + if (button.AutomationId is null) + { + button.AutomationId = $"BottomBarButton{index}".ToDUIAutomationId(); + } } grid.BindingContext = BindingContext; diff --git a/src/tests/unittests/Components/BottomSheets/BottomSheetTests.cs b/src/tests/unittests/Components/BottomSheets/BottomSheetTests.cs new file mode 100644 index 000000000..9b2e4fff6 --- /dev/null +++ b/src/tests/unittests/Components/BottomSheets/BottomSheetTests.cs @@ -0,0 +1,25 @@ +using DIPS.Mobile.UI.Components.BottomSheets; +using Button = Microsoft.Maui.Controls.Button; + +namespace DIPS.Mobile.UI.UnitTests.Components.BottomSheets; + +public class BottomSheetTests +{ + [Fact] + public void CreateBottomBar_PreservesConsumerAutomationIdsAndGeneratesMissingIds() + { + var buttonWithConsumerId = new Button { AutomationId = "Shared_ViewOptions_ResetButton" }; + var buttonWithoutConsumerId = new Button(); + var bottomSheet = new BottomSheet { ShowBottombarButtonsOnSubViews = true }; + + bottomSheet.BottombarButtons.Add(buttonWithConsumerId); + bottomSheet.BottombarButtons.Add(buttonWithoutConsumerId); + + var createBottomBar = () => bottomSheet.CreateBottomBar(); + + createBottomBar.Should().NotThrow(); + + buttonWithConsumerId.AutomationId.Should().Be("Shared_ViewOptions_ResetButton"); + buttonWithoutConsumerId.AutomationId.Should().Be("DUI.BottomSheet.BottomBarButton1"); + } +}