Repository navigation
Commit 2a2a79d
authored
Clear cached directional focus history on a non-directional focus request (flutter#187957)
Fixes flutter#85941
When a user traverses focus nodes directionally (e.g. using `up`, `down`
arrow keys), we maintain a history stack of visited nodes (called
`policyData`). This allows us to avoid
[hysteresis](https://en.wikipedia.org/wiki/Hysteresis) when a user
switches direction (i.e. switching from `down` to `up`) - meaning, the
forward traversal path and the reversed traversal path should match.
However, before this change, we were not detecting when a focus request
occurred due to some outside event (e.g. a direct focus request from a
tap on the screen). That means when a user switched direction, we would
include the node they had tapped on in the history stack, and
unexpectedly visit it.
We now clear the stack (see method `propagateFocusRequest`) if a node is
focused on outside of a directional navigation event.
**Before:**
<img width="454" height="656" alt="before"
src="https://github.com/user-attachments/assets/26e3cdd2-2f39-4dc8-9616-4f21d4afcc52"
/>
**With fix:**
<img width="454" height="656" alt="fixed"
src="https://github.com/user-attachments/assets/0e795e0c-8e07-4422-beed-f371407b4ae6"
/>
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md1 parent 5f8d728 commit 2a2a79d
2 files changed
Lines changed: 204 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
| 1126 | + | |
1126 | 1127 | | |
1127 | 1128 | | |
1128 | 1129 | | |
| |||
1154 | 1155 | | |
1155 | 1156 | | |
1156 | 1157 | | |
1157 | | - | |
| 1158 | + | |
1158 | 1159 | | |
1159 | 1160 | | |
1160 | 1161 | | |
| |||
1214 | 1215 | | |
1215 | 1216 | | |
1216 | 1217 | | |
| 1218 | + | |
1217 | 1219 | | |
1218 | 1220 | | |
1219 | 1221 | | |
1220 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
1221 | 1229 | | |
1222 | 1230 | | |
1223 | 1231 | | |
1224 | 1232 | | |
1225 | 1233 | | |
1226 | | - | |
| 1234 | + | |
1227 | 1235 | | |
| 1236 | + | |
1228 | 1237 | | |
1229 | 1238 | | |
1230 | 1239 | | |
1231 | 1240 | | |
1232 | | - | |
| 1241 | + | |
1233 | 1242 | | |
| 1243 | + | |
1234 | 1244 | | |
1235 | 1245 | | |
1236 | 1246 | | |
| |||
1240 | 1250 | | |
1241 | 1251 | | |
1242 | 1252 | | |
1243 | | - | |
| 1253 | + | |
1244 | 1254 | | |
| 1255 | + | |
1245 | 1256 | | |
1246 | 1257 | | |
1247 | 1258 | | |
1248 | 1259 | | |
1249 | | - | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
1250 | 1265 | | |
1251 | 1266 | | |
1252 | 1267 | | |
1253 | 1268 | | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1254 | 1287 | | |
1255 | 1288 | | |
1256 | 1289 | | |
| 1290 | + | |
1257 | 1291 | | |
1258 | 1292 | | |
1259 | 1293 | | |
| |||
1275 | 1309 | | |
1276 | 1310 | | |
1277 | 1311 | | |
1278 | | - | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
1279 | 1319 | | |
1280 | 1320 | | |
1281 | 1321 | | |
| |||
1296 | 1336 | | |
1297 | 1337 | | |
1298 | 1338 | | |
1299 | | - | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1300 | 1346 | | |
1301 | 1347 | | |
1302 | 1348 | | |
| |||
1321 | 1367 | | |
1322 | 1368 | | |
1323 | 1369 | | |
| 1370 | + | |
1324 | 1371 | | |
1325 | 1372 | | |
1326 | 1373 | | |
1327 | | - | |
| 1374 | + | |
| 1375 | + | |
1328 | 1376 | | |
1329 | 1377 | | |
1330 | 1378 | | |
1331 | | - | |
| 1379 | + | |
1332 | 1380 | | |
1333 | 1381 | | |
| 1382 | + | |
1334 | 1383 | | |
1335 | 1384 | | |
1336 | 1385 | | |
1337 | | - | |
| 1386 | + | |
1338 | 1387 | | |
1339 | 1388 | | |
| 1389 | + | |
1340 | 1390 | | |
1341 | 1391 | | |
1342 | 1392 | | |
1343 | 1393 | | |
1344 | | - | |
| 1394 | + | |
1345 | 1395 | | |
1346 | 1396 | | |
1347 | 1397 | | |
| |||
1351 | 1401 | | |
1352 | 1402 | | |
1353 | 1403 | | |
1354 | | - | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1355 | 1411 | | |
1356 | | - | |
| 1412 | + | |
1357 | 1413 | | |
1358 | 1414 | | |
1359 | 1415 | | |
| |||
2206 | 2262 | | |
2207 | 2263 | | |
2208 | 2264 | | |
2209 | | - | |
2210 | | - | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
2211 | 2270 | | |
2212 | 2271 | | |
2213 | 2272 | | |
| |||
2216 | 2275 | | |
2217 | 2276 | | |
2218 | 2277 | | |
| 2278 | + | |
| 2279 | + | |
2219 | 2280 | | |
2220 | 2281 | | |
2221 | 2282 | | |
| |||
2232 | 2293 | | |
2233 | 2294 | | |
2234 | 2295 | | |
| 2296 | + | |
2235 | 2297 | | |
2236 | 2298 | | |
2237 | 2299 | | |
2238 | 2300 | | |
2239 | 2301 | | |
| 2302 | + | |
2240 | 2303 | | |
2241 | 2304 | | |
2242 | 2305 | | |
| |||
2262 | 2325 | | |
2263 | 2326 | | |
2264 | 2327 | | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
2265 | 2346 | | |
2266 | 2347 | | |
2267 | 2348 | | |
| |||
0 commit comments