Skip to content

Conversation

@TahaTesser
Copy link
Member

This relands #131609


fixes PopupMenuItem adds redundant padding when using ListItem

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.

… padding and update default horizontal padding for Material 3 (#131609)

fixes [`PopupMenuItem` adds redundant padding when using `ListItem`](#128553)

### Description

- Fixed redundant `ListTile` padding when using `CheckedPopupMenuItem` or  `PopupMenuItem`  with the `ListTile` child for complex popup menu items as suggested in the docs.
- Updated default horizontal padding for popup menu items.

### Code sample

<details> 
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

/// Flutter code sample for [PopupMenuButton].

// This is the type used by the popup menu below.
enum SampleItem { itemOne, itemTwo, itemThree }

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

class PopupMenuApp extends StatelessWidget {
  const PopupMenuApp({super.key});

  @OverRide
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: const PopupMenuExample(),
    );
  }
}

class PopupMenuExample extends StatefulWidget {
  const PopupMenuExample({super.key});

  @OverRide
  State<PopupMenuExample> createState() => _PopupMenuExampleState();
}

class _PopupMenuExampleState extends State<PopupMenuExample> {
  SampleItem? selectedMenu;

  @OverRide
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('PopupMenuButton')),
      body: Center(
        child: SizedBox(
          width: 150,
          height: 100,
          child: Align(
            alignment: Alignment.topLeft,
            child: PopupMenuButton<SampleItem>(
              initialValue: selectedMenu,
              // Callback that sets the selected popup menu item.
              onSelected: (SampleItem item) {
                setState(() {
                  selectedMenu = item;
                });
              },
              itemBuilder: (BuildContext context) =>
                  <PopupMenuEntry<SampleItem>>[
                const PopupMenuItem<SampleItem>(
                  value: SampleItem.itemOne,
                  child: Text('PopupMenuItem'),
                ),
                const CheckedPopupMenuItem<SampleItem>(
                  checked: true,
                  value: SampleItem.itemTwo,
                  child: Text('CheckedPopupMenuItem'),
                ),
                const PopupMenuItem<SampleItem>(
                  value: SampleItem.itemOne,
                  child: ListTile(
                    leading: Icon(Icons.cloud),
                    title: Text('ListTile'),
                    contentPadding: EdgeInsets.zero,
                    trailing: Icon(Icons.arrow_right_rounded),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
``` 
	
</details>

### Before

![image](https://github.com/flutter/flutter/assets/48603081/aad15ffb-ca11-4997-81d1-b46288161a4e)

- Default horizontal padding is the same as M2 (16.0), while the specs use a smaller value (12.0)
- `ListTile` nested by default in `CheckedPopupMenuItem` has redundant padding
- `PopupMenuItem` using `ListTile` as a child for complex menu items contains redundant padding.

![Screenshot 2023-07-31 at 17 17 08](https://github.com/flutter/flutter/assets/48603081/75ad1fe5-e051-42ba-badf-e20c799dee96)

### After 

- Default horizontal padding is updated for Material 3.
- `PopupMenuItem` & `CheckedPopupMenuItem` override `ListTile` padding (similar to how `ExpansionTile` overrides `ListTile` text and icon color.

![Screenshot 2023-07-31 at 17 17 25](https://github.com/flutter/flutter/assets/48603081/288cf892-5b51-4365-9855-5ef0ed2928e9)
@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Aug 15, 2023
@CaseyHillers CaseyHillers self-assigned this Aug 15, 2023
@CaseyHillers
Copy link
Contributor

FYI I'll land this in the evening (PDT) to minimize disruption.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

@HansMuller
Copy link
Contributor

@CaseyHillers - thanks for your help with this!

@CaseyHillers CaseyHillers added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 16, 2023
@auto-submit auto-submit bot merged commit 23315f1 into flutter:master Aug 16, 2023
@TahaTesser TahaTesser deleted the reland-131609 branch August 16, 2023 07:18
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 16, 2023
flutter/flutter@f0e7c51...2502b51

2023-08-16 [email protected] Roll Flutter Engine from f186f1e9dc88 to 70b5700b79f6 (1 revision) (flutter/flutter#132655)
2023-08-16 [email protected] Roll Flutter Engine from e8670f03a9b1 to f186f1e9dc88 (2 revisions) (flutter/flutter#132649)
2023-08-16 [email protected] Fix flutter_tools use of --local-engine-host (flutter/flutter#132648)
2023-08-16 [email protected] Roll Flutter Engine from 7cc6a5832a0e to e8670f03a9b1 (3 revisions) (flutter/flutter#132623)
2023-08-16 [email protected] Roll Flutter Engine from decaccfc421d to 7cc6a5832a0e (1 revision) (flutter/flutter#132621)
2023-08-16 [email protected] Roll Flutter Engine from 659cdfc5a568 to decaccfc421d (6 revisions) (flutter/flutter#132618)
2023-08-16 [email protected] Roll Flutter Engine from 7409ce4ba0a8 to 659cdfc5a568 (1 revision) (flutter/flutter#132612)
2023-08-16 [email protected] Revert "Reorganize and clarify API doc generator" (flutter/flutter#132613)
2023-08-16 [email protected] Roll Flutter Engine from a9da7212eacf to 7409ce4ba0a8 (5 revisions) (flutter/flutter#132609)
2023-08-16 [email protected] Roll Flutter Engine from 22f03ffdc290 to a9da7212eacf (4 revisions) (flutter/flutter#132608)
2023-08-16 [email protected] [Reland] #131609 (flutter/flutter#132555)
2023-08-15 [email protected] Explain the keyboard manager protocol (flutter/flutter#132533)
2023-08-15 [email protected] Fix extent for null returning builder in GridView (flutter/flutter#132511)
2023-08-15 [email protected] Reorganize and clarify API doc generator (flutter/flutter#132353)
2023-08-15 [email protected] Fixing a memory leak in About box/dialog overlays (flutter/flutter#130842)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App 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.

PopupMenuItem adds redundant padding when using ListItem

3 participants