mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add focus/blur commands to View (#53828)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53828 Adds focus and blur commands to Android views. Changelog: [Internal] Reviewed By: rozele Differential Revision: D82644681 fbshipit-source-id: 96fa6370e177c91742d285b0b158b77447d105f6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2945fa6e0e
commit
14458d8699
+8
@@ -416,6 +416,14 @@ public open class ReactViewGroup public constructor(context: Context?) :
|
||||
updateClippingToRect(clippingRect, excludedViews)
|
||||
}
|
||||
|
||||
internal fun requestFocusFromJS() {
|
||||
super.requestFocus(FOCUS_DOWN, null)
|
||||
}
|
||||
|
||||
internal fun clearFocusFromJS() {
|
||||
super.clearFocus()
|
||||
}
|
||||
|
||||
override fun endViewTransition(view: View) {
|
||||
super.endViewTransition(view)
|
||||
childrenRemovedWhileTransitioning?.remove(view.id)
|
||||
|
||||
+14
@@ -404,6 +404,8 @@ public open class ReactViewManager : ReactClippingViewManager<ReactViewGroup>()
|
||||
when (commandId) {
|
||||
HOTSPOT_UPDATE_KEY -> handleHotspotUpdate(root, args)
|
||||
"setPressed" -> handleSetPressed(root, args)
|
||||
"focus" -> handleFocus(root)
|
||||
"blur" -> handleBlur(root)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -428,4 +430,16 @@ public open class ReactViewManager : ReactClippingViewManager<ReactViewGroup>()
|
||||
val y = args.getDouble(1).dpToPx()
|
||||
root.drawableHotspotChanged(x, y)
|
||||
}
|
||||
|
||||
private fun handleFocus(root: ReactViewGroup) {
|
||||
if (ReactNativeFeatureFlags.enableImperativeFocus()) {
|
||||
root.requestFocusFromJS()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleBlur(root: ReactViewGroup) {
|
||||
if (ReactNativeFeatureFlags.enableImperativeFocus()) {
|
||||
root.clearFocusFromJS()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user