Skip to content

Commit 3717536

Browse files
Add breaking change doc for Visibility widget changes (#12488)
_Description of what this PR is changing or adding, and why:_ This PR adds a breaking change document around `Visibility` changes that landed in stable release 3.35. _Issues fixed by this PR (if any):_ Fixes [#174652](flutter/flutter#174652) _PRs or commits this PR depends on (if any):_ Does not depend on any PRs that have not already landed in stable. Related PRs: flutter/flutter#159133 ## Presubmit checklist - [] If you are unwilling, or unable, to sign the CLA, even for a _tiny_, one-word PR, please file an issue instead of a PR. - [] If this PR is not meant to land until a future stable release, mark it as draft with an explanation. - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style)—for example, it doesn't use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first-person pronouns). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
1 parent d59b954 commit 3717536

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/content/release/breaking-changes/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ They're sorted by release and listed in alphabetical order:
7171
* [The `Form` widget no longer supports being a sliver][]
7272
* [Flutter now sets default `abiFilters` in Android builds][]
7373
* [Merged threads on macOS and Windows][]
74+
* [The `Visibility` widget is no longer focusable by default when `maintainState` is enabled][]
7475

7576
[Component theme normalization updates]: /release/breaking-changes/component-theme-normalization-updates
7677
[Deprecate `DropdownButtonFormField` `value` parameter in favor of `initialValue`]: /release/breaking-changes/deprecate-dropdownbuttonformfield-value
@@ -80,6 +81,7 @@ They're sorted by release and listed in alphabetical order:
8081
[The `Form` widget no longer supports being a sliver]: /release/breaking-changes/form-semantics
8182
[Flutter now sets default `abiFilters` in Android builds]: /release/breaking-changes/default-abi-filters-android
8283
[Merged threads on macOS and Windows]: /release/breaking-changes/macos-windows-merged-threads
84+
[The `Visibility` widget is no longer focusable by default when `maintainState` is enabled]: /release/breaking-changes/visibility-maintainfocusability
8385

8486
<a id="released-in-flutter-332" aria-hidden="true"></a>
8587
### Released in Flutter 3.32
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: The Visibility widget is no longer focusable by default when maintainState is enabled
3+
description: >-
4+
The Visibility widget by default no longer implicitly retains focusability
5+
for its child when maintainState is enabled.
6+
---
7+
8+
## Summary
9+
This change was introduced to fix an issue
10+
where an `IndexedStack`s hidden children would be focusable with keyboard events
11+
(see [issue](https://github.com/flutter/flutter/issues/114213))
12+
due to the underlying `Visibility` widgets default behavior.
13+
14+
## Description of change
15+
The core change is the `Visibility` widget is no longer focusable by default
16+
when `maintainState` is enabled.
17+
A new flag, `maintainFocusability`, must be set to true with `maintainState`
18+
for a hidden widget to remain focusable.
19+
20+
## Migration guide
21+
If your app has a `Visibility` widget that does not set `maintainState` to true,
22+
then no changes are required.
23+
24+
If your app has a `Visibility` widget that sets `maintainState` to true
25+
and you relied on the previous default behavior
26+
that allowed you to focus your hidden widget,
27+
you will need to set `maintainFocusability` to true.
28+
29+
Code before migration:
30+
31+
```dart
32+
child: Visibility(
33+
maintainState: true,
34+
child: SomeWidget(),
35+
)
36+
```
37+
38+
Code after migration:
39+
40+
```dart
41+
child: Visibility(
42+
maintainState: true,
43+
maintainFocusability: true,
44+
child: SomeWidget(),
45+
)
46+
```
47+
48+
## Timeline
49+
50+
Landed in version: 3.34.0-pre<br>
51+
In stable release: 3.35
52+
53+
## References
54+
55+
API documentation:
56+
57+
* [`Visibility`]({{site.api}}/flutter/widgets/Visibility-class.html)
58+
59+
Relevant issues:
60+
61+
* [Issue 114213]({{site.repo.flutter}}/issues/114213)
62+
63+
Relevant PRs:
64+
65+
* [PR 159133: Add flag to exclude focus for hidden children in Visibility, maintainFocusability. Set maintainFocusability to false in IndexedStack]({{site.repo.flutter}}/pull/159133)

0 commit comments

Comments
 (0)