From a2040d797e7895d017afa7780079ad13bb93636a Mon Sep 17 00:00:00 2001 From: Doris Cheng Date: Thu, 31 Oct 2024 17:09:46 -0700 Subject: [PATCH] Make activity section header in Community Notifications Settings not focusable Summary: As part of the Android Accessibility Wave, we want to remove **keyboard focus** for the "Activity" header of the Community Notification Settings This is because keyboard focus should only focus on relevant screen content. Since the "Activity" heading is considered a "non-interactive" element, we want to remove it from keyboard focus. This diff: - Replaces `focusable` with `screenReaderFocusable` for **MigSectionHeader** - Adds `focusable` to **MigSectionHeaderCTASpec**. That way, the header only gets focusability when it's interactive - Add new test cases to test that the header is screen reader focusable and is only focusable if it's interactive Differential Revision: D64793278 fbshipit-source-id: cf6fb3243f8e48ecd3905390ac23aa03e690f6ab --- .../main/java/com/facebook/litho/DebugLayoutNode.kt | 3 +++ .../testing/subcomponents/InspectableComponent.java | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/litho-core/src/main/java/com/facebook/litho/DebugLayoutNode.kt b/litho-core/src/main/java/com/facebook/litho/DebugLayoutNode.kt index be0794825fa..e4ecf758e7a 100644 --- a/litho-core/src/main/java/com/facebook/litho/DebugLayoutNode.kt +++ b/litho-core/src/main/java/com/facebook/litho/DebugLayoutNode.kt @@ -57,6 +57,9 @@ class DebugLayoutNode internal constructor(private val result: LithoLayoutResult val focusable: Boolean get() = node.nodeInfo?.focusState == NodeInfo.FOCUS_SET_TRUE + val screenReaderFocusable: Boolean + get() = node.nodeInfo?.screenReaderFocusState == NodeInfo.SCREEN_READER_FOCUS_SET_TRUE + val contentDescription: CharSequence? get() = node.nodeInfo?.contentDescription diff --git a/litho-testing/src/main/java/com/facebook/litho/testing/subcomponents/InspectableComponent.java b/litho-testing/src/main/java/com/facebook/litho/testing/subcomponents/InspectableComponent.java index b9135aaa679..439c3a34d00 100644 --- a/litho-testing/src/main/java/com/facebook/litho/testing/subcomponents/InspectableComponent.java +++ b/litho-testing/src/main/java/com/facebook/litho/testing/subcomponents/InspectableComponent.java @@ -252,7 +252,15 @@ public Integer getImportantForAccessibility() { */ public boolean getFocusable() { final DebugLayoutNode layout = mComponent.getLayoutNode(); - return layout == null ? false : layout.getFocusable(); + return layout != null && layout.getFocusable(); + } + + /** + * @return The boolean value of the screenReaderFocusable property on this debug component. + */ + public boolean getScreenReaderFocusable() { + final DebugLayoutNode layout = mComponent.getLayoutNode(); + return layout != null && layout.getScreenReaderFocusable(); } /**