Skip to content

Conversation

@TahaTesser
Copy link
Member

@TahaTesser TahaTesser commented Dec 7, 2021

Fixes #94701

Complete details #94701 (comment)

Based on this feedback, I notice a lot of inner snackbar widget instances already have clip.none as default, and I also tried the material widget with a container for clip.none yet the clipping was not going away then I realized, ClipRect is actually the widget that is doing this clipping here. Replacing this widget with a simple container solves the clipping but it does affect a few golden tests as expected.

Golden "material.snack_bar.goldenTest.workWithBottomSheet.png": Pixel test failed, 0.16% diff detected.

Before After

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Dec 7, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@TahaTesser
Copy link
Member Author

cc: @Piinks

I can see ClipRect was added in https://github.com/flutter/flutter/pull/66504/files#diff-f28e065ae18b9a43c269b6b6e56ceb417084872226ea345fd3e3e207837f0f3dR563

Is it necessary for Hero transition? Is this a good change? If you have any alternative fix

@skia-gold
Copy link

Gold has detected about 6 new digest(s) on patchset 1.
View them at https://flutter-gold.skia.org/cl/github/94811

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #94811 at sha 7409d4e

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Dec 7, 2021
@Piinks
Copy link
Contributor

Piinks commented Dec 7, 2021

I don't think it was necessary for the Hero, the ClipRect was already there before I made that change.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

I am not sure why there was a ClipRect there to begin with, I would look in the git history to see if it was intentional so we don't introduce a regression.

There is a duplicate issue that is closed:

It was fixed by:

So either we regressed already, or the bug was never fixed and was closed accidentally (those PRs all appear to be related to positioning). In either case, we should add more explicit tests so we know for sure if this comes up again in the future.

@TahaTesser
Copy link
Member Author

TahaTesser commented Dec 8, 2021

@Piinks
Thanks so much for the feedback, I just realized, it wasn't added but kept

I already looked into #47202 and its PRs, it seems to be a related position indeed and it shows shadow being clipped at the bottom by navigation but the new issue is only reproducible when you force a width and horizontal sides are clipped (this parameter wasn't available in that version of Fluttter where this was handled).

This seems to be a common issue that also affects other widgets with elevation too

Here I created a basic code sample that doesn't use Snackbar at all, just to demonstrate what's happening with ClipRect and container without horizontal margin and this issue seems to beyond Snackbar since it would affect any widget with elevation

Screenshot 2021-12-08 at 11 32 58

minimal code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Material App',
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Material App Bar'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            ClipRect(
              child: Container(
                margin: const EdgeInsets.only(bottom: 15, top: 10),
                width: 300,
                child: const Material(
                    elevation: 8,
                    shape: RoundedRectangleBorder(),
                    child: Padding(
                      padding: EdgeInsets.all(8.0),
                      child:
                          Text('ClipRect > Container(width: 300) > Material'),
                    )),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(bottom: 15, top: 10),
              width: 300,
              child: const Material(
                  elevation: 8,
                  shape: RoundedRectangleBorder(),
                  child: Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Text('Container(width: 300) > Material'),
                  )),
            ),
            ClipRect(
              child: Container(
                margin: const EdgeInsets.only(bottom: 15, top: 10, left: 15, right: 15),
                child: const Material(
                    elevation: 8,
                    shape: RoundedRectangleBorder(),
                    child: Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Text('Container with horizontal margins > Material'),
                    )),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

return Hero(
tag: '<SnackBar Hero tag - ${widget.content}>',
child: ClipRect(child: snackBarTransition),
child: Container(child: snackBarTransition),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just remove the Container?

@skia-gold
Copy link

Gold has detected about 10 new digest(s) on patchset 2.
View them at https://flutter-gold.skia.org/cl/github/94811

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #94811 at sha cafd91a

@TahaTesser
Copy link
Member Author

@Piinks
Thanks for the suggestion, without container, there are still golden test diffs

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Thanks @TahaTesser! I am surprised the analyzer did not complain about an empty Container wrapper.
This and the golden files LGTM! The bot does not recognize that those are tests, I'll reach out to @Hixie for exception. :)

@Hixie
Copy link
Contributor

Hixie commented Dec 13, 2021

test-exempt: is tested (gold)

Looks like this also breaks some Google-internal tests, you'll need to ask someone to take a look at those to see if it's anything serious or just more golden tests. Ask around in #hackers-tests.

@Piinks
Copy link
Contributor

Piinks commented Dec 13, 2021

Thanks @Hixie! I have taken a look at the Google-internal failures. They all look as expected, there is just a sliver of shadow that was previously being clipped incorrectly, similar to the golden file updates here.
Will manually set the check to green here and follow up when it rolls. 👍

@fluttergithubbot fluttergithubbot merged commit ae442ee into flutter:master Dec 13, 2021
@TahaTesser TahaTesser changed the title Replace ClipRect in Snackbar with a Container for Clip.none clip behavior Remove ClipRect from Snackbar Dec 13, 2021
@TahaTesser TahaTesser deleted the snackbar_clip branch December 14, 2021 08:08
@TahaTesser TahaTesser mentioned this pull request Feb 11, 2022
8 tasks
@flar
Copy link
Contributor

flar commented Feb 11, 2022

If there is a BackdropFilter involved it will suddenly blur the entire screen rather than just the contents under the widget. As per BackdropFilter:

The filter will be applied to all the area within its parent or ancestor widget's clip. If there's no clip, the filter will be applied to the full screen.

In fact, this change caused a customer issue of this exact nature: #98205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Floating Snackbar with set width has clipped shadow

6 participants