Skip to content
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

Added a "justify" to the ExpanderControl component to make the icon v… #6570

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aheintz
Copy link

@aheintz aheintz commented Jan 7, 2023

What does this PR do?

Fixing two visual bugs.

  1. Added a justify="center" to the ExpanderControl component to make the icon vertically centered and to handle non-standard themes or styling.
  2. Fixed a rendering problem where the first line of the Datatable was selected if using Cmd-Tab to move back to the browser window and triggering an event in use-keyboard.js which caused this effect. Removed the "usingKeyboard", the only case I could find where this would be applicable would be using the onSelect use-case, but that still works as intended after manual testing. I would appreciate some input whether which is correct though.

Where should the reviewer start?

src/components/DataTable/ExpanderCell.js and src/components/DataTable/Body.js are the only files changed except the updated snapshot.

What testing has been done on this PR?

  1. Manual testing with different themes to verify the icon's position. The snapshot changes also indicate that the only affected are vertical (flexbox) alignment.
  2. Manual tests of the removal of the usingKeyboard, I might need help here to verify it's not affecting something I'm not aware of, I'm not too familiar with grommet.

How should this be manually tested?

The storybooks should suffice.

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

This partially resolves #6344

Screenshots (if appropriate)

Do the grommet docs need to be updated?

No

Should this PR be mentioned in the release notes?

No

Is this change backwards compatible or is it a breaking change?

Backwards compatible

…ertically centered and to handle non-standard themes or styling.

Removed the "usingKeyboard", it conflicted with switching apps (at least on mac) using Cmd-Tab and rendered the top row focused/active independent on which rows was expanded. The only case I could find where this would be applicable would be using the "onSelect" use-case, but that still works as intended after manual testing. I would appreciate some input whether which is correct though.
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Thanks for your work so far on this! I just added some initial comments and thoughts for potential directions we could head. Let me know what you think

src/js/components/DataTable/Body.js Outdated Show resolved Hide resolved
align="center"
fill
pad={pad}
justify="center"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there are cases where it is desirable to not have the expander icon vertically centered. For example if you have a DataTable with rows that take up a lot of vertical space, having the expander icon at the top of the row makes it easier to associate with the row (see screenshots below)

Expander icon with justify="center"
Screen Shot 2023-01-10 at 3 48 20 PM

Expander icon without justify="center"
Screen Shot 2023-01-10 at 3 48 33 PM

I understand a use case like this might not always be the case, but I'm just hesitating to make justify="center" the default.

Another note on this. It looks like verticalAlign is being passed through but isn't having an effect on the expander cell. This could be something to look into. Perhaps instead of making justify="center" the default we can utilize verticalAlign so that people can control this?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your feedback! Those screenshots definitively make it look like a poor idea! 🙈
I'll take a look into verticalAlign.

Copy link
Author

Choose a reason for hiding this comment

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

I've updated the PR with your input. I would really like to remove fill on the Expander Button, I think it's ugly that it's filling the entire height, but I also think it wouldn't be appreciated to change the default behaviour... Overriding with theme setting possibly?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I think a theme setting would make sense. Maybe dataTable.expand that can accept button props?

- Expander button now takes `verticalAlign` into account and not using justify. Updated storybook to show this.
- "Restored" useKeyboard with the condition it should only be used if `onClickRow` is used (i.e. that is the only case when a row should get focus).
@jcfilben jcfilben added the waiting Awaiting response to latest comments label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Awaiting response to latest comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datatable rowDetails poor component interaction and visual bugs
2 participants