Skip to content

Change cursor when hovering on DropdownButton #80567

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

Merged

Conversation

jushutch
Copy link
Contributor

@jushutch jushutch commented Apr 16, 2021

Implement functionality to change the mouse cursor when hovering over a DropdownButton widget. Currently there is no cursor change, which is unlike the current HTML standard and the standard across similar widgets, such as the IconButton widget. Added a MouseRegion with a default clickable cursor, inspired by the IconButton widget implementation. The changes are minimal and lightweight by only implementing a default cursor, and they can be easily extended in the future.

Also added a DropdownButton test in dropdown_test.dart to test that the mouse cursor changes appropriately when the button is both enabled and disabled.

This PR addresses issue #77136.

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 feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 16, 2021
@google-cla google-cla bot added the cla: yes label Apr 16, 2021
@Hixie
Copy link
Contributor

Hixie commented Apr 21, 2021

cc @gspencergoog @dkwingsmt

Implement functionality to change the mouse cursor to a
clickable cursor when hovering on the DropdownButton, similar
to the IconButton and TextField widgets.

flutter#77136
Add one test that verifies cursor behavior when hovering
over the DropdownButton widget, both when enabled and
disabled.

flutter#77136
@jushutch jushutch force-pushed the 77136-dropdown-button-cursor branch from ea9331c to d33c5de Compare April 21, 2021 21:49
@HansMuller HansMuller requested a review from dkwingsmt April 22, 2021 23:48
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the change!

await gesture.moveTo(offDropdownButton);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);

// Test that mouse cursor doesn't change when button is disabled
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to split this test into a separate one. See https://github.com/flutter/flutter/wiki/Writing-Effective-Tests#one-behavior-per-test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay sounds good, thanks for the feedback!

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants