Skip to content

CupertinoTextSelectionToolbar clips all buttons when one of them is too long #138177

@luccasclezar

Description

@luccasclezar

Is there an existing issue for this?

Steps to reproduce

  1. Create a TextField with custom ContextMenuButtonItems
  2. Set the second item's text to be very long

I set the text in the code sample to be excessively long to be able to reproduce this on devices with the default font size, but this is a big issue for accessibility users that increase their system font size as the button text needs to be way shorter than this for the bug to happen.

Expected results

The second item should be the only one clipped.

Actual results

All items after the second are clipped.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: SizedBox(
            height: 400,
            width: 200,
            child: TextField(
              contextMenuBuilder: (context, state) =>
                  AdaptiveTextSelectionToolbar(
                anchors: state.contextMenuAnchors,
                children: [
                  ...AdaptiveTextSelectionToolbar.getAdaptiveButtons(
                    context,
                    [
                      ContextMenuButtonItem(
                        onPressed: () {},
                        label: 'Select all',
                      ),
                      ContextMenuButtonItem(
                        onPressed: () {},
                        label: 'Very very very very very very long text here',
                      ),
                      ContextMenuButtonItem(
                        onPressed: () {},
                        label: 'Other button',
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2023-11-09.at.17.45.13.mov

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel beta, 3.16.0-0.3.pre, on macOS 13.2.1 22D68 darwin-x64, locale en-BR)
    • Flutter version 3.16.0-0.3.pre on channel beta at /usr/local/Caskroom/flutter/3.0.5/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 476aa717cd (3 weeks ago), 2023-10-19 20:10:52 -0500
    • Engine revision 91cde06da0
    • Dart version 3.2.0 (build 3.2.0-210.3.beta)
    • DevTools version 2.28.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc4)
    • Android SDK at /Users/luccas/Library/Developer/Xamarin/android-sdk-macosx
    • Platform android-34, build-tools 34.0.0-rc4
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.84.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.76.0

[✓] Connected device (3 available)
    • iPhone Xʀ (mobile) • 54553294-CF00-4B9D-B85D-8C8501385E77 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 13.2.1 22D68
      darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome
      119.0.6045.123

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: cupertinoflutter/packages/flutter/cupertino repositoryfound in release: 3.13Found to occur in 3.13found in release: 3.17Found to occur in 3.17frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions