Skip to content

Commit

Permalink
Set IsTabStop to false when tabIndex is negative (#4180)
Browse files Browse the repository at this point in the history
* Set IsTabStop to false when tabIndex is negative

* Change files

* remove unneeded static_cast

* whoops actually did need the static_cast

* clearValue and set -1 as default
  • Loading branch information
lamxdoan committed Feb 27, 2020
1 parent 8f61d93 commit dfc57fc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 9 additions & 0 deletions 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"
}
11 changes: 9 additions & 2 deletions vnext/ReactUWP/Views/ControlViewManager.cpp
Expand Up @@ -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<int32_t>(tabIndex))
control.TabIndex(static_cast<int32_t>(tabIndex));
if (tabIndex == static_cast<int32_t>(tabIndex)) {
if (tabIndex < 0) {
control.IsTabStop(false);
control.ClearValue(winrt::Control::TabIndexProperty());
} else {
control.IsTabStop(true);
control.TabIndex(static_cast<int32_t>(tabIndex));
}
}
} else if (propertyValue.isNull()) {
control.ClearValue(winrt::Control::TabIndexProperty());
}
Expand Down
13 changes: 10 additions & 3 deletions vnext/ReactUWP/Views/ViewViewManager.cpp
Expand Up @@ -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() {
Expand Down Expand Up @@ -206,7 +213,7 @@ class ViewShadowNode : public ShadowNodeBase {

bool m_enableFocusRing = true;
bool m_onClick = false;
int32_t m_tabIndex = std::numeric_limits<std::int32_t>::max();
int32_t m_tabIndex = -1;

winrt::ContentControl::GotFocus_revoker m_contentControlGotFocusRevoker{};
winrt::ContentControl::LostFocus_revoker m_contentControlLostFocusRevoker{};
Expand Down

0 comments on commit dfc57fc

Please sign in to comment.