[Fabric][Composition] Expose a non-mutating focusability API on ComponentView (e.g. IsFocusable ) for FocusZone / single-tab-stop scenarios
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- cpp, react-native
- 领域
- desktop-dev, frontend
调研方向
首先跟踪 Composition 实现中的 ComponentView.TryFocus 以及所请求的非变更式可聚焦性入口点。然后检查 Composition.FocusManager.FindFirstFocusableElement、FindLastFocusableElement 和 GettingFocusEventArgs.TrySetNewFocusedComponent,包括 IFocusManagerStatics 激活路径。完成的标准是:无需移动焦点即可使用主要查询,并且面向托管 RNW 应用的次要 API 行为已得到澄清或修复。
由索引模型根据 Issue 内容生成。
描述
Problem Description
Building a FocusZone / single-tab-stop control on Composition (New Architecture) requires identifying the next focusable ComponentView in tab order. Today there is no non-mutating way to test whether a ComponentView can take focus, so we must call ComponentView.TryFocus(...) in a loop — which moves focus as a side effect while probing. We need a query API that reports focusability without changing focus.
What we're doing
Native RCTFocusZone implementation. On Tab we want to move focus to the first focusable element outside the zone in one transition; arrow keys navigate within. To find that element we DFS the tree and call TryFocus on each candidate until one succeeds, because there's no way to ask "is this focusable?" first.
Gaps
- No non-mutating focusability property on ComponentView . Requesting an IsFocusable / Focusable (get-only bool ) property, so we can select the correct target without side-effecting focus.
- Composition.FocusManager.FindFirstFocusableElement / FindLastFocusableElement statics throw — their activation factory ( IFocusManagerStatics ) isn't registered in the runtime we load, so get_activation_factory throws (fatal inside a noexcept input handler). If these are the intended API, they need to be usable from a hosted RNW app.
- GettingFocusEventArgs.TrySetNewFocusedComponent(ComponentView) projects as void (no success bool ), so we can't redirect focus during GettingFocus and know whether it was accepted, forcing focus logic into KeyDown instead.
Ask
Primarily (1) a non-mutating focusability query on ComponentView . Secondarily, clarify/fix (2) and (3) so focus navigation can be built without trial-and-error TryFocus .
Workaround
DFS + TryFocus trial-and-error in KeyDown , which mutates focus while probing and costs a tree walk per keystroke.
Steps To Reproduce
- In a react-native-windows Fabric (Composition / New Architecture) app, add a native
component (e.g. a custom FocusZone) that subclasses the codegen ComponentView and, in
Initialize, registers a KeyDown handler on the container ComponentView. - In that handler, try to move keyboard focus to the next focusable ComponentView in tab
order (e.g. on Tab, the first focusable element outside the zone). To do this you must
determine which ComponentView can accept focus. - Look for a non-mutating way to test whether a given ComponentView is focusable. There is
none: ComponentView.TryFocus(FocusState) is the only option, and it moves focus as a
side effect while probing. - Result: you have to call TryFocus in a loop across candidate views, causing focus to
actually move during probing, and there is no API to identify the correct target up front.
Expected Results
No response
CLI version
CLI version is 13.6.9
Environment
react-native-windows 0.81.5 (Fabric / Composition), Microsoft.ReactNative C++/WinRT
Community Modules
No response
Target React Native Architecture
None
Target Platform Version
None
Visual Studio Version
None
Build Configuration
None
Snack, code example, screenshot, or link to a repository
No response
- 主要语言
- C++
- 星标
- 17.4k
- 派生
- 1.2k
- 平均合并
- 3 天 7 小时
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/react-native-windows 的其他 Issue
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/react-native-windows#16340 ·
维护者通常 2 天内回复
-
bug Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/react-native-windows#16321 · 1 条评论 ·
维护者通常 2 天内回复
-
bug Needs: Triage :mag:
难度 3/5 1-2 天 新手友好度 48/100
microsoft/react-native-windows#16479 ·
维护者通常 2 天内回复
-
Needs: Triage :mag:
难度 5/5 一周以上 新手友好度 30/100
microsoft/react-native-windows#16442 · 2 条评论 ·
维护者通常 2 天内回复
-
Fabric: activating the window doesn't announce the window or the focused control to a screen reader未关闭Needs: Triage :mag:
难度 4/5 3-5 天 新手友好度 48/100
microsoft/react-native-windows#16435 ·
维护者通常 2 天内回复
查看 microsoft/react-native-windows 的全部 Issue
相似的 Issue
-
Mac mini M6 (16 GB): Q2_0 streaming works - measured 11.7->27.2 tok/s + arena fix for sub-32 GB Macs未关闭
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
champion good first issue remake source/qq
难度 2/5 1-3 小时 新手友好度 65/100
metasequoiaime/msime-windows#1025 ·
维护者通常 1 天内回复
-
backlog bug
难度 2/5 1-3 小时 新手友好度 75/100
EchoTools/nevr-runtime#653 ·
维护者通常 1 天内回复
-
`--fail-require-skip` never fires: run_tests.py searches stdout, but the unittest binary writes the skip summary to stderr可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
InfiniTimeOrg/InfiniTime#2492 ·