From 72c82d399f743819ee6c013b705adba69e791e4f Mon Sep 17 00:00:00 2001 From: Russel Neiss Date: Mon, 16 Mar 2026 10:00:53 -0400 Subject: [PATCH 1/2] Restore a11y functionality on Android --- .../date_picker/generated/NumberPicker.java | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java b/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java index e4b48efc..7cb7f691 100644 --- a/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java +++ b/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java @@ -2442,6 +2442,46 @@ class AccessibilityNodeProviderImpl extends AccessibilityNodeProvider { private int mAccessibilityFocusedView = UNDEFINED; + /** + * Check if the NumberPicker is visible to the user in a React Native-compatible way. + * This avoids issues with the platform's isVisibleToUser() method in RN context. + */ + private boolean isPickerVisibleToUser() { + // Check if the view and all its parents are visible + if (!NumberPicker.this.isShown()) { + return false; + } + + // Check if the view has positive dimensions + if (NumberPicker.this.getWidth() <= 0 || NumberPicker.this.getHeight() <= 0) { + return false; + } + + // Check if the view is actually attached to a window + if (NumberPicker.this.getWindowVisibility() != View.VISIBLE) { + return false; + } + + return true; + } + + /** + * Check if a child element with given bounds is visible to the user. + */ + private boolean isPickerVisibleToUser(Rect bounds) { + // First check if the picker itself is visible + if (!isPickerVisibleToUser()) { + return false; + } + + // Check if the bounds have positive dimensions + if (bounds == null || bounds.isEmpty()) { + return false; + } + + return true; + } + @Override public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { switch (virtualViewId) { @@ -2740,7 +2780,7 @@ private AccessibilityNodeInfo createAccessibiltyNodeInfoForInputText( } Rect boundsInParent = mTempRect; boundsInParent.set(left, top, right, bottom); -// info.setVisibleToUser(isVisibleToUser(boundsInParent)); + info.setVisibleToUser(isPickerVisibleToUser(boundsInParent)); info.setBoundsInParent(boundsInParent); Rect boundsInScreen = boundsInParent; int[] locationOnScreen = mTempArray; @@ -2764,7 +2804,7 @@ private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int vi info.setAccessibilityFocused(mAccessibilityFocusedView == virtualViewId); Rect boundsInParent = mTempRect; boundsInParent.set(left, top, right, bottom); -// info.setVisibleToUser(isVisibleToUser(boundsInParent)); + info.setVisibleToUser(isPickerVisibleToUser(boundsInParent)); info.setBoundsInParent(boundsInParent); Rect boundsInScreen = boundsInParent; int[] locationOnScreen = mTempArray; @@ -2813,8 +2853,8 @@ private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int lef // boundsInParent.scale(applicationScale); info.setBoundsInParent(boundsInParent); -// info.setVisibleToUser(isVisibleToUser()); - + info.setVisibleToUser(isPickerVisibleToUser()) + Rect boundsInScreen = boundsInParent; int[] locationOnScreen = mTempArray; getLocationOnScreen(locationOnScreen); @@ -2887,4 +2927,4 @@ public static android.view.accessibility.AccessibilityManager getInstance(Contex (android.view.accessibility.AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); return accessibilityManager; } -} \ No newline at end of file +} From 3076a9078052fab780a07b25d61f203c598dc6b2 Mon Sep 17 00:00:00 2001 From: Russel Neiss Date: Mon, 30 Mar 2026 10:48:44 -0400 Subject: [PATCH 2/2] Update android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oğuzhan Selim Temiz --- .../com/henninghall/date_picker/generated/NumberPicker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java b/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java index 7cb7f691..cf588160 100644 --- a/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java +++ b/android/src/main/java/com/henninghall/date_picker/generated/NumberPicker.java @@ -2853,7 +2853,7 @@ private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int lef // boundsInParent.scale(applicationScale); info.setBoundsInParent(boundsInParent); - info.setVisibleToUser(isPickerVisibleToUser()) + info.setVisibleToUser(isPickerVisibleToUser()); Rect boundsInScreen = boundsInParent; int[] locationOnScreen = mTempArray;