fix(a11y): ios voiceover crash during touch (#9318)

closes https://github.com/NativeScript/NativeScript/issues/9317
This commit is contained in:
Nathan Walker
2021-04-09 08:35:00 -07:00
committed by GitHub
parent 8739e8d6cf
commit 9a407ce989

View File

@@ -73,18 +73,18 @@ function ensureNativeClasses() {
]); ]);
nativeFocusedNotificationObserver = Application.ios.addNotificationObserver(UIAccessibilityElementFocusedNotification, (args: NSNotification) => { nativeFocusedNotificationObserver = Application.ios.addNotificationObserver(UIAccessibilityElementFocusedNotification, (args: NSNotification) => {
const uiView = args.userInfo.objectForKey(UIAccessibilityFocusedElementKey) as UIView; const uiView = args.userInfo?.objectForKey(UIAccessibilityFocusedElementKey) as UIView;
if (!uiView.tag) { if (!uiView?.tag) {
return; return;
} }
const rootView = Application.getRootView(); const rootView = Application.getRootView();
// We use the UIView's tag to find the NativeScript View by its domId. // We use the UIView's tag to find the NativeScript View by its domId.
let view = rootView.getViewByDomId<View>(uiView.tag); let view = rootView.getViewByDomId<View>(uiView?.tag);
if (!view) { if (!view) {
for (const modalView of <Array<View>>rootView._getRootModalViews()) { for (const modalView of <Array<View>>rootView._getRootModalViews()) {
view = modalView.getViewByDomId(uiView.tag); view = modalView.getViewByDomId(uiView?.tag);
if (view) { if (view) {
break; break;
} }