diff --git a/change/react-native-windows-2020-02-25-11-32-44-tabindex.json b/change/react-native-windows-2020-02-25-11-32-44-tabindex.json new file mode 100644 index 00000000000..29082acf039 --- /dev/null +++ b/change/react-native-windows-2020-02-25-11-32-44-tabindex.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "comment": "Set IsTabStop to false when tabIndex is negative", + "packageName": "react-native-windows", + "email": "lamdoan@microsoft.com", + "commit": "27a16dc9783aefa04c5035c4c2a4b39e8d11f6f8", + "dependentChangeType": "patch", + "date": "2020-02-25T19:32:43.976Z" +} \ No newline at end of file diff --git a/vnext/ReactUWP/Views/ControlViewManager.cpp b/vnext/ReactUWP/Views/ControlViewManager.cpp index 579a1cbe515..e0bbc4fc1e4 100644 --- a/vnext/ReactUWP/Views/ControlViewManager.cpp +++ b/vnext/ReactUWP/Views/ControlViewManager.cpp @@ -64,8 +64,15 @@ void ControlViewManager::UpdateProperties(ShadowNodeBase *nodeToUpdate, const fo } else if (propertyName == "tabIndex") { if (propertyValue.isNumber()) { auto tabIndex = propertyValue.asDouble(); - if (tabIndex == static_cast(tabIndex)) - control.TabIndex(static_cast(tabIndex)); + if (tabIndex == static_cast(tabIndex)) { + if (tabIndex < 0) { + control.IsTabStop(false); + control.ClearValue(winrt::Control::TabIndexProperty()); + } else { + control.IsTabStop(true); + control.TabIndex(static_cast(tabIndex)); + } + } } else if (propertyValue.isNull()) { control.ClearValue(winrt::Control::TabIndexProperty()); } diff --git a/vnext/ReactUWP/Views/ViewViewManager.cpp b/vnext/ReactUWP/Views/ViewViewManager.cpp index adcf4824ac4..1a19bb24260 100644 --- a/vnext/ReactUWP/Views/ViewViewManager.cpp +++ b/vnext/ReactUWP/Views/ViewViewManager.cpp @@ -87,8 +87,15 @@ class ViewShadowNode : public ShadowNodeBase { void TabIndex(int32_t tabIndex) { m_tabIndex = tabIndex; - if (IsControl()) - GetControl().TabIndex(m_tabIndex); + if (IsControl()) { + if (tabIndex < 0) { + GetControl().IsTabStop(false); + GetControl().ClearValue(winrt::Control::TabIndexProperty()); + } else { + GetControl().IsTabStop(true); + GetControl().TabIndex(tabIndex); + } + } } bool OnClick() { @@ -206,7 +213,7 @@ class ViewShadowNode : public ShadowNodeBase { bool m_enableFocusRing = true; bool m_onClick = false; - int32_t m_tabIndex = std::numeric_limits::max(); + int32_t m_tabIndex = -1; winrt::ContentControl::GotFocus_revoker m_contentControlGotFocusRevoker{}; winrt::ContentControl::LostFocus_revoker m_contentControlLostFocusRevoker{};