Skip to content

[DataTable] Hide arrow padding when not sorting#51667

Merged
dkwingsmt merged 6 commits intoflutter:masterfrom
dkwingsmt:fix-data-table-on-sort
Mar 13, 2020
Merged

[DataTable] Hide arrow padding when not sorting#51667
dkwingsmt merged 6 commits intoflutter:masterfrom
dkwingsmt:fix-data-table-on-sort

Conversation

@dkwingsmt
Copy link
Contributor

Description

This PR fixes the problem that the arrow padding still displays when DataColumn.onSort is null, thus allowing the label to be truly centered.

This continues the work of #43735 by @andermoran.

Related Issues

Tests

I added the following tests:

  • DataTable column heading cell - no sort
  • DataTable correctly renders with a mouse

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Feb 28, 2020
@dkwingsmt dkwingsmt changed the title [DataTable] Hide arrow [DataTable] Hide arrow padding when not sorting Mar 11, 2020
/// some text.
///
/// By default, this widget will only occupy the minimal space. If you want
/// it to take the entire remaining space, e.g. when you want to use [Center],
Copy link
Contributor

Choose a reason for hiding this comment

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

Would using an Expanded be the only way to center the label? Would it be possible to set a size of space to take up?

Copy link
Contributor Author

@dkwingsmt dkwingsmt Mar 12, 2020

Choose a reason for hiding this comment

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

Sorry if I misunderstood your question. The problem here is the widget structure, which is roughly:

TableCell
 |- Row
      |- label
      |- arrow & padding

the default behavior is to align everything left, including the label and the arrow (right if numerical), and the only thing the developer can control is label.

We can't provide an Expanded by default since it changes the behavior to aligning label left and arrow right.

We might actually have to provide a new parameter alignment for full flexibility, but since it'll be a new feature & parameter, I'd rather not do in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha!

)),
));

{
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these brackets enclosing? Here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These brackets are only to scope nameText and nameCell between subtests so that I don't have to either use nameText1 nameText2 etc, or declare 5 empty variables at the start of the test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know! Thanks!

expect(find.descendant(of: nameCell, matching: find.byType(Icon)), findsOneWidget);
}

await tester.pumpWidget(MaterialApp(
Copy link
Contributor

Choose a reason for hiding this comment

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

This last pumpWidget and the following expectations looks like the first one, why do we check it again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a suggestion by Hixie that we test turning it on then off again just to make sure. I added comment to explain the intention, hopefully it's clearer.

expect(tester.renderObject(find.text('column2')).attached, true);

// Wait for the tooltip timer
await tester.pumpAndSettle(const Duration(seconds: 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to check something after this pumpAndSettle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. This pumpAndSettle is mostly to prevent an exception thrown by Tooltip when its timer expires and schedules a new frame when the view has been destroyed. I've updated the comment to make it clearer.

@dkwingsmt
Copy link
Contributor Author

@Piinks I've addressed the issues you brought up, can you take a look again? Thanks!

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

LGTM!

@dkwingsmt dkwingsmt merged commit c82c399 into flutter:master Mar 13, 2020
@dkwingsmt dkwingsmt deleted the fix-data-table-on-sort branch March 13, 2020 01:20
@lock
Copy link

lock bot commented Apr 2, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

4 participants