Skip to content

[Chip] Chip with onDeleted but without onPressed has no ripple when tapping delete button. #43534

@pennzht

Description

@pennzht

Description

On a chip with a delete button but without onPressed, there is currently no ripple on the delete button when it is pressed.

Behavior before merging #42779

  • Tapping on a chip with only onPressed creates one ripple;
  • Tapping on a chip with onPressed and onDeleted on the delete icon creates two ripples, one for the whole chip and one for the delete icon; (unexpected)
  • Tapping on a chip with only onDeleted creates one ripple;
  • Tapping on a chip with neither onPressed nor onDeleted creates no ripples.

(Highlights are not counted as ripples.)

The pull request #42779 fixes the issue b/140930220; after #42779, there is only one ripple when the delete icon is tapped on a chip with onPressed and onDeleted. But this pull request creates the following behavior:

Behavior after merging #42779 (current master)

  • Tapping on a chip with only onPressed creates one ripple;
  • Tapping on a chip with onPressed and onDeleted on the delete icon creates one ripple for the delete icon only;
  • Tapping on a chip with only onDeleted creates no ripples; (unexpected)
  • Tapping on a chip with neither onPressed nor onDeleted creates no ripples.

(Tapping the delete button still calls onDeleted as expected. Holding down the delete button still shows a tooltip.)

Expected behavior

  • Tapping on a chip with only onPressed creates one ripple;
  • Tapping on a chip with onPressed and onDeleted on the delete icon creates one ripple for the delete icon only;
  • Tapping on a chip with only onDeleted creates one ripple for the delete icon only;
  • Tapping on a chip with neither onPressed nor onDeleted creates no ripples.

Clarifications are needed for the following behavior:

  • When a chip with a delete button is pressed (on the delete button), should the whole chip be highlighted?
  • When a chip with a delete button is pressed (on the delete button), should the whole chip be elevated?

Related issues

Steps to reproduce

  1. Create a new flutter project and save the following code as main.dart.
  2. Run the project (with flutter on branch master).
  3. Press and hold different parts of each chip to see how the ripples behave.
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RawChip(
                label: Text('Chip with onPressed'),
                onPressed: () {},
            ),
            RawChip(
                label: Text('Chip with onPressed and onDeleted'),
                onDeleted: () {},
                onPressed: () {},
            ),
            RawChip(
                label: Text('Chip with onDeleted only'),
                onDeleted: () {},
            ),
            RawChip(
                label: Text('Inactive chip'),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots

  • Test app
    home_screen
  • Tapping first chip
    tap_1
  • Tapping second chip
    tap_2
  • Tapping delete icon on second chip (master)
    tap_2_delete_button
  • Tapping delete icon on second chip (previous version)
    previous_doubleripple
  • Tapping delete icon on third chip (previous version)
    previous_ripple

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.found in release: 1.22Found to occur in 1.22found in release: 1.26Found to occur in 1.26frameworkflutter/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 version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions