react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.69k stars 128 forks source link

Focus Management: Get currently focused element #640

Open s77rt opened 1 year ago

s77rt commented 1 year ago

Introduction

Hi :wave:! On Web (ReactJS/RNW) the blur event contains info about the new to-be-focused element (nativeEvent.relatedTarget). This is really helpful to know how to act in certain scenarios. Unfortunately, we don't have such a feature on Native. But can we have it? Or get close to it?

Details

I understand that we may not have control over the blur event due to host limitations. However, the value we are looking for here is not strictly tied to the blur event i.e. nativeEvent.relatedTarget will return the newly focused element. So as an alternative can we just ask the OS which element is currently focused?

I'm looking to understand the requirements/challenges that may be blocking us from implementing this feature.

Discussion points

s77rt commented 1 year ago

How can we ask the OS to return the currently focused element?