Skip to content

Commit a933add

Browse files
Vetle444Vetle Finstad
andauthored
Fix BottomSheet bottom bar automation IDs (#913)
Co-authored-by: Vetle Finstad <finstad@Vetles-MacBook-Pro-2.local>
1 parent 429d999 commit a933add

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [62.0.1]
2+
- [BottomSheet] Fixed crash when bottom bar buttons already have consumer-provided `AutomationId` values.
3+
14
## [62.0.0]
25
- [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.
36
- [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.

src/library/DIPS.Mobile.UI/Components/BottomSheets/BottomSheet.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ public Grid CreateBottomBar()
109109
grid.AddColumnDefinition(new ColumnDefinition(GridLength.Star));
110110
var index = grid.ColumnDefinitions.Count - 1;
111111
grid.Add(button, index);
112-
button.AutomationId = $"BottomBarButton{index}".ToDUIAutomationId<BottomSheet>();
112+
if (button.AutomationId is null)
113+
{
114+
button.AutomationId = $"BottomBarButton{index}".ToDUIAutomationId<BottomSheet>();
115+
}
113116
}
114117

115118
grid.BindingContext = BindingContext;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using DIPS.Mobile.UI.Components.BottomSheets;
2+
using Button = Microsoft.Maui.Controls.Button;
3+
4+
namespace DIPS.Mobile.UI.UnitTests.Components.BottomSheets;
5+
6+
public class BottomSheetTests
7+
{
8+
[Fact]
9+
public void CreateBottomBar_PreservesConsumerAutomationIdsAndGeneratesMissingIds()
10+
{
11+
var buttonWithConsumerId = new Button { AutomationId = "Shared_ViewOptions_ResetButton" };
12+
var buttonWithoutConsumerId = new Button();
13+
var bottomSheet = new BottomSheet { ShowBottombarButtonsOnSubViews = true };
14+
15+
bottomSheet.BottombarButtons.Add(buttonWithConsumerId);
16+
bottomSheet.BottombarButtons.Add(buttonWithoutConsumerId);
17+
18+
var createBottomBar = () => bottomSheet.CreateBottomBar();
19+
20+
createBottomBar.Should().NotThrow();
21+
22+
buttonWithConsumerId.AutomationId.Should().Be("Shared_ViewOptions_ResetButton");
23+
buttonWithoutConsumerId.AutomationId.Should().Be("DUI.BottomSheet.BottomBarButton1");
24+
}
25+
}

0 commit comments

Comments
 (0)