From 4cc2a1cda0326cfe2fcff309d750dc82dc9e5693 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 6 Aug 2020 18:25:12 -0400 Subject: [PATCH] shim accessibility for testers. --- MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index 8994b340..a00603da 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -63,8 +63,13 @@ - (void)amendAccesibilityLabel { NSString *amendment = [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"]; - if (![self.buttonView.label.accessibilityLabel hasPrefix:amendment]) { - self.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", amendment, self.buttonView.label.accessibilityLabel]; + NSString *accessibilityLabel = self.buttonView.label.accessibilityLabel; + if (!accessibilityLabel) { + // The accessibility label is nil when in non-voice over mode. Therefore assign the label text for the voice over is turned on mid-session (i.e. testers 🤦). + accessibilityLabel = self.buttonView.label.text; + } + if (accessibilityLabel && ![accessibilityLabel hasPrefix:amendment]) { + self.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", amendment, accessibilityLabel]; } }