-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Make the barrier panel on the Material Drawer non-dismissible #164810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Make the barrier panel on the Material Drawer non-dismissible #164810
Conversation
…roperty named drawerDismissible
// If set to false, prevents the barrier behind the [Drawer] from being dismissed. | ||
// Defaults to true. The value of this flag also gets inherited by the parent Scaffold, | ||
// or can be overridden if a [DrawerController] is extended and this value set accordingly. | ||
final bool drawerDismissible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why we call it drawerDismissible
here instead of simply dismissible
, since this is already known as a DrawerController. (I know some other properties are also prefixed with "drawer", which also appears weird to me.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd totally be open to call it dismissible - I was just trying to keep the existing convention which I also thought it was a bit redundant but didn't want to have to change the rest if there was a purpose for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Can you rename it to dismissible
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do!
/// If false, and a [drawer] is specified, then the barrier behind the drawer should not | ||
/// respond to a tap event and thus remain open. The default behavior is to close upon the | ||
/// user tapping on the barrier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same doc style guide problem as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, this should be split into 2 paragraphs so that the first paragraph is a single sentence, per the styleguide.
@@ -27,4 +27,109 @@ void main() { | |||
await tester.pumpAndSettle(); | |||
expect(findHeadingLevelOnes, findsOne); | |||
}); | |||
|
|||
testWidgets('drawer is dismissible', (WidgetTester tester) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless it's intentional, test cases should reside in packages/flutter/test/material/drawer_test.dart
, not a11y_assessments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, not intentional. I actually saw some of the other drawer tests there so I wanted to put them along with the rest, but these can easily be moved wherever is more appropriate.
Co-authored-by: Tong Mu <[email protected]>
…missible"; moved tests topackages/flutter/test/material/drawer_test.dart
Can you move the test to the unit test file? (
|
…ally_assessments; left the ones there as they were before
One analyzer issue missing
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…omanejaquez/flutter into drawer_barrier_non_dismissible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small things here, and it looks like the analyzer is failing. Thank you for the PR!
Is there an issue for this by the way?
/// If false, and a [drawer] is specified, then the barrier behind the drawer should not | ||
/// respond to a tap event and thus remain open. The default behavior is to close upon the | ||
/// user tapping on the barrier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, this should be split into 2 paragraphs so that the first paragraph is a single sentence, per the styleguide.
), | ||
); | ||
|
||
// check the flag is set at the Scaffold level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Capital letter at the start and period at the end, here and elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took care of the comments above. However for the comment on the scaffold.dart, for the first sentence I had to split it into 2 because it would exceed the max length on a comment line.
Fixed the punctuation and capitalization on the other comments - thank you for catching that.
@@ -851,3 +1003,5 @@ void main() { | |||
}); | |||
}); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these newlines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha - addressed the newline issue on the drawer_test.dart, but for some reason the Linux analyzer keeps barking on the newline not being added.
Co-authored-by: Tong Mu <[email protected]>
Co-authored-by: Tong Mu <[email protected]>
|
The analyzer errors seem to be only format errors, which can be resolved by running |
will do 👍 |
Hi, the tree-status red check is not related to your PR, but actually that Flutter's CI being flaky. It will resolve with time. I've requested @/justinmc for a secondary review. After a 2nd approval we can land this PR. You're not needed to do anything now (unless you want to tweak something, of course). :) |
Sweet! Yeah I noticed that it succeeds one time, then it fails the other - so i thought of kicking it off once again and try my luck. It'd be great for this to make it in. Thanks @dkwingsmt for your help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits 👍
/// If false, and a [drawer] is specified, then the barrier behind the drawer should not respond to a tap event and thus remain open. | ||
/// The default behavior is to close upon the user tapping on the barrier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be an empty line of ///
in between these two.
Also, check the 80 character line limit.
@@ -339,6 +339,7 @@ class DrawerController extends StatefulWidget { | |||
this.scrimColor, | |||
this.edgeDragWidth, | |||
this.enableOpenDragGesture = true, | |||
this.dismissible = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe this should be called barrierDismissible or something like that to avoid people thinking that it means the drawer can not be closed at all? A bunch of routes like ModalRoute have barrierDismissible properties.
I'm happy to defer to you though @romanejaquez, if you think the current name is better then let's stick with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar naming in an in-flight PR: #166896
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you suggest naming it "barrierDismissible"? I kinda like it more than "drawerDismissible" now. I think we can change it to "barrierDismissible" across the board. how about "drawerBarrierDismissible"? too long?
@@ -1708,6 +1708,7 @@ class Scaffold extends StatefulWidget { | |||
this.primary = true, | |||
this.drawerDragStartBehavior = DragStartBehavior.start, | |||
this.extendBody = false, | |||
this.drawerDismissible = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this would become drawerBarrierDismissible if we went with that name from my other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought drawerDismissible was more descriptive when it is set via the Scaffold, to go along with the other related drawer-related properties. I don't mind making it dismissible on both sides if y'all are ok with it. However, after @justinmc comment, i feel like we should rename it to drawerBarrierDismissible. Would it be too long of a name?
final ScaffoldState state = tester.firstState(find.byType(Scaffold)); | ||
state.openEndDrawer(); | ||
|
||
await tester.pump(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this initial pump if you also pump a duration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, removed it - must've been left over from my tests.
state.openEndDrawer(); | ||
|
||
await tester.pump(); | ||
await tester.pump(const Duration(seconds: 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be more accurate as 246ms?
const Duration _kBaseSettleDuration = Duration(milliseconds: 246); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be dumb but why isn't this a pumpAndSettle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced it with the pumpAndSettle and it worked as well, which I think is cleaner. I believe I was testing for the duration of the animation of the drawer, which was another PR that I had related to it. Will replace with the pumpAndSettle instead.
|
||
expect(find.byType(Drawer), findsExactly(1)); | ||
|
||
// Tap on the modal barrier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to delete this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah meant to remove that one. Will remove it.
This PR entails making the modal barrier behind the Material Drawer dismissible / non-dismissible via a Scaffold flag named "drawerBarrierDismissible", as in:
This is so as to force the Drawer to be opened / closed programmatically using either:
or
and the user not closing the Drawer upon tapping on the modal barrier.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on [Discord].