Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changes to disabled property for components (e.g TouchableHighlight) #11278

Merged
merged 13 commits into from
Mar 2, 2023

Conversation

YajurG
Copy link
Contributor

@YajurG YajurG commented Feb 23, 2023

Description

Added changes to prevent components that are disabled from being keyboard focusable. Used TouchableHighlight issue #8875 as example.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

Resolves [#8875 ]

What

Added logic to check disabled property on components and, if true, make them not focusable.

Screenshots

After:
image

Breakpoint on disabled={true}
image

Testing

Tested on a TouchableHighlight component in playground. When disabled prop is set to true, Touchable component no longer receives keyboard focus, both in and out of Narrator mode, as shown in 'After' screenshot. Also, breakpoint for disabled property check in ViewViewManager is being hit when Touchable component has disabled={true}.

Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow

@YajurG YajurG marked this pull request as ready for review February 28, 2023 19:18
@YajurG YajurG requested review from a team as code owners February 28, 2023 19:18
vnext/PropertySheets/Warnings.props Outdated Show resolved Hide resolved
packages/playground/Samples/simple.tsx Outdated Show resolved Hide resolved
@@ -124,7 +128,7 @@ void ControlViewManager::OnPropertiesUpdated(ShadowNodeBase *node) {

// If developer specifies either the accessible and focusable prop to be false
// remove accessibility and keyboard focus for component.
const auto isTabStop = (node->IsAccessible() && node->IsFocusable());
const auto isTabStop = node->IsDisable() ? false : node->IsAccessible() && node->IsFocusable();
Copy link
Contributor

@AgneLukoseviciute AgneLukoseviciute Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use bang operator here

const auto isTabStop =
(isPressable && isFocusable && isAccessible) || (!isPressable && (isFocusable || isAccessible));
const auto isDisabled = pViewShadowNode->IsDisable();
const auto isTabStop = (isDisabled ? false : ((isPressable && isFocusable && isAccessible) || (!isPressable && (isFocusable || isAccessible))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same here re ! operator


protected:
XamlView m_view;
bool m_updating = false;
bool m_isFocusable = true;
bool m_isAccessible = true;
bool m_isDisable = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider naming this m_isDisabled and the above to IsDisabled to align with the disabled property name.

if (finalizeBorderRadius && control.try_as<xaml::Controls::IControl7>()) {
// Control.CornerRadius is only supported on >= RS5, setting borderRadius on Controls have no effect < RS5
UpdateCornerRadiusOnElement(nodeToUpdate, control);
// Control.CornerRadius is only supported on >= RS5, setting borderRadius on Controls have no effect < RS5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: white space

@jonthysell
Copy link
Contributor

It's worth testing that it works for <Text> components. Pressable supports disabled and the first example in the Pressable docs is:

<Pressable onPress={onPressFunction}>
  <Text>I'm pressable!</Text>
</Pressable>

const auto isTabStop =
(isPressable && isFocusable && isAccessible) || (!isPressable && (isFocusable || isAccessible));
(!isDisabled &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you haven't already, I'd also double check that this issue (#10687) isn't being reintroduced just with the disabled prop causing it now

@YajurG YajurG merged commit cb93a6c into microsoft:main Mar 2, 2023
@YajurG YajurG linked an issue Mar 2, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disabled TouchableHighlight still receives keyboard focus
5 participants