Skip to content

Conversation

@shihaohong
Copy link
Contributor

@shihaohong shihaohong commented Feb 11, 2020

Description

Relands #47616, but as an opt-in change to allow developers to migrate to the fixed version. The original PR caused golden tests to fail since the SnackBar's offset was updated.

Screenshots

Before fix

After fix

Migration guide

  1. Set all instances of Scaffold.shouldSnackBarIgnoreFABRect to true after this PR is merged.
  2. Fix all failing tests. There are likely two main types:
    a) Fix all golden tests to expect the new change.
    b) Fix any widget tests that expect the SnackBar to appear higher than it should. The difference should simply be the size of the floating action button's rect.
  3. Once Scaffold.shouldSnackBarIgnoreFABRect is set to true by default (in a subsequent PR), remove the parameter from all instances of Scaffold.

Related Issues

Addresses #47202
Addresses #43716

Tests

I added the following tests:

  • Same tests as original PR, but with the shouldSnackBarIgnoreFABRect flag turned on.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

filaps and others added 7 commits February 6, 2020 21:46
Now the test checks certain position Y of FAB
added tests for testing height of SnackBar.
…n' to group 'SnackBar position'

improved test by removing padding details, and renaming.
… group "SnackBar position"

and improved test for testing with universal behavior
@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Feb 11, 2020
@shihaohong
Copy link
Contributor Author

shihaohong commented Feb 11, 2020

cc/ @filaps If you're okay with these changes, could you consent to the CLA? Please feel free to make any suggestions to the PR if you have any as well

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@shihaohong shihaohong changed the title Snackbar fix soft break Step 1: SnackBarBehavior.floating offset fix - Soft breaking change Feb 11, 2020
'is present when it is not. This parameter will be removed. '
'This feature was deprecated after v1.15.3.'
)
final bool shouldSnackBarIgnoreFABRect;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - why not just make this static?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would that work? Would all Flutter apps then simply set Scaffold.shouldSnackBarIgnoreFABRect = true before they call runApp?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It's not something we expect people to want to use, let alone to use differently for different scaffolds.

Presumably they could even set it after runApp, but they should probably do it before any builds kick off to avoid weirdness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/// This flag is deprecated and fixes and issue with incorrect clipping
/// and positioning of the [SnackBar] set to [SnackBarBehavior.floating].
@Deprecated(
'Fixes a bug that that fixes clipping and positioning of SnackBar '
Copy link
Contributor

@filaps filaps Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
'Fixes a bug that that fixes clipping and positioning of SnackBar '
'Fixes a bug that fixes clipping and positioning of SnackBar '

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized the wording in general was off, so I changed it to the following if that's okay:

    'Fixes a bug that incorrectly clips and positions SnackBar. It '
    'previously incorrectly offsets itself assuming a floating action button '
    'is present even when it is not. This parameter will be removed. '
    'This feature was deprecated after v1.15.3.'

@filaps
Copy link
Contributor

filaps commented Feb 12, 2020

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@filaps
Copy link
Contributor

filaps commented Feb 12, 2020

LGTM.
Thank you so much for help with "breaking change process"!

@required this.isSnackBarFloating,
@required this.extendBody,
@required this.extendBodyBehindAppBar,
@required this.shouldSnackBarIgnoreFABRect,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ditch this and just acccess the static property.

Comment on lines 1322 to 1325
'Fixes a bug that incorrectly clips and positions SnackBar. It '
'previously incorrectly offsets itself assuming a floating action button '
'is present even when it is not. This parameter will be removed. '
'This feature was deprecated after v1.15.3.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe something like:

This property controls whether to clip and position the snackbar as if there is always a floating action button, even if one is not present. It exists to provide backwards compatibility to ease migrations, and will eventually be removed.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some nits

@shihaohong shihaohong merged commit 1f3d423 into flutter:master Feb 13, 2020
@shihaohong shihaohong deleted the snackbar-fix-soft-break branch April 3, 2020 19:07
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants