Skip to content

Let accessible be std::optional in native #51630

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ - (NSArray *)accessibilityElements
// If the component is not `accessible`, we return an empty array.
// We do this because logically all nested <Text> components represent the content of the <Paragraph> component;
// in other words, all nested <Text> components individually have no sense without the <Paragraph>.
if (!_textView.state || !paragraphProps.accessible) {
if (!_textView.state || !paragraphProps.accessible.value_or(false)) {
return [NSArray new];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &

// `accessible`
if (oldViewProps.accessible != newViewProps.accessible) {
self.accessibilityElement.isAccessibilityElement = newViewProps.accessible;
self.accessibilityElement.isAccessibilityElement = newViewProps.accessible.value_or(false);
}

// `accessibilityLabel`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ void FocusOrderingHelper::traverseAndUpdateNextFocusableElement(
// focused and present in the hierarchy
if (currNode->getTraits().check(ShadowNodeTraits::Trait::KeyboardFocusable) ||
(props != nullptr &&
(props->focusable || props->accessible || props->hasTVPreferredFocus))) {
(props->focusable || props->accessible.value_or(false) ||
props->hasTVPreferredFocus))) {
LayoutMetrics nodeLayoutMetrics = uimanager.getRelativeLayoutMetrics(
*currNode, parentShadowNode.get(), {.includeTransform = true});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AccessibilityProps {

#pragma mark - Props

bool accessible{false};
std::optional<bool> accessible{std::nullopt};
std::optional<AccessibilityState> accessibilityState{std::nullopt};
std::string accessibilityLabel;
std::vector<std::string> accessibilityOrder{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode<
BaseShadowNode::orderIndex_ = 0;
}

// TODO why is this not needed
bool isKeyboardFocusable =
HostPlatformViewTraitsInitializer::isKeyboardFocusable(props) ||
props.accessible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void ViewShadowNode::initialize() noexcept {

bool formsStackingContext = !viewProps.collapsable ||
viewProps.pointerEvents == PointerEventsMode::None ||
!viewProps.nativeId.empty() || viewProps.accessible ||
!viewProps.nativeId.empty() || viewProps.accessible.value_or(false) ||
viewProps.opacity != 1.0 || viewProps.transform != Transform{} ||
(viewProps.zIndex.has_value() &&
viewProps.yogaStyle.positionType() != yoga::PositionType::Static) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
}

if (accessible != oldProps->accessible) {
result["accessible"] = accessible;
result["accessible"] = accessible.value_or(false);
}

if (getClipsContentToBounds() != oldProps->getClipsContentToBounds()) {
Expand Down
Loading