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

fix: Fix visual bugs in drawer toggle buttons #1343

Merged
merged 1 commit into from
Jul 20, 2023
Merged

Conversation

just-boris
Copy link
Member

Description

Fix focus and hover style issues with drawer triggers.

Updated the non-drawer toggle buttons too, to have unified implementation

Related links, issue #, if available: n/a

How has this been tested?

  • PR build
  • Visual regression tests in my pipeline
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (b80535d) 93.46% compared to head (36bc0cc) 93.46%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1343   +/-   ##
=======================================
  Coverage   93.46%   93.46%           
=======================================
  Files         623      623           
  Lines       16731    16733    +2     
  Branches     5527     5527           
=======================================
+ Hits        15637    15639    +2     
  Misses       1021     1021           
  Partials       73       73           
Impacted Files Coverage Δ
src/app-layout/visual-refresh/drawers.tsx 84.28% <ø> (ø)
src/app-layout/drawer/index.tsx 97.61% <100.00%> (ø)
src/app-layout/mobile-toolbar/index.tsx 92.85% <100.00%> (ø)
src/app-layout/toggles/index.tsx 100.00% <100.00%> (ø)
src/app-layout/visual-refresh/trigger-button.tsx 100.00% <100.00%> (ø)
src/test-utils/dom/app-layout/index.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -91,13 +91,14 @@ function setupTest(
'drawers focus toggles between open and close buttons',
setupTest(
async page => {
await page.click(wrapper.findDrawersTriggers().get(2).toSelector());
const triggerSelector = wrapper.findDrawerTriggerById('pro-help').toSelector();
Copy link
Member Author

Choose a reason for hiding this comment

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

:nth-child does not work anymore, because every button has a wrapper now.

Since this feature is not in production yet, we can do such breaking changes

Comment on lines +11 to +12
$_toggle-padding-horizontal: 0.7 * styles.$base-size;
$_toggle-padding-vertical: awsui.$space-xxs;
Copy link
Member Author

Choose a reason for hiding this comment

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

Prefix a variable with underscore makes it available only inside the current file

Comment on lines +52 to +54
&.drawer-content-clickable {
cursor: pointer;
color: awsui.$color-text-interactive-default;
Copy link
Member Author

Choose a reason for hiding this comment

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

Made some refactoring in this file to more clearly connect styles and their reasons.

Why is there a pointer cursor? Not because the drawer is closed, but because it is clickable

Copy link
Member Author

Choose a reason for hiding this comment

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

There could be closed non-clickable drawers and the new CSS structure allows that

@@ -63,34 +62,26 @@ $drawer-z-index-mobile: 1001;
}
}

.trigger {
.drawer-content > .drawer-triggers > & {
Copy link
Member Author

Choose a reason for hiding this comment

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

Before this PR, app layout used our button component and this line overrode button styles.

Overriding styles is bad even if done for a good reason, it still may cause issues.

In this PR I replaced it with custom styles on top of native <button> tag (see the <ToggleButton> component) which has the correct styles from the start, without overrides

@@ -12,7 +12,6 @@
}

.mobile-bar {
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed anymore with our current browser support

@@ -8,6 +9,7 @@ export interface AppLayoutButtonProps {
ariaExpanded?: boolean;
iconName?: IconProps.Name;
iconSvg?: React.ReactNode;
onClick: () => void;
onClick?: () => void;
Copy link
Member Author

Choose a reason for hiding this comment

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

Made it optional, because in some cases, the wrapper element is clickable and button does not have an its own listener

@@ -331,7 +331,6 @@ export type ColorsTokenName =
| 'colorForegroundControlDefault'
| 'colorForegroundControlDisabled'
| 'colorShadowDefault'
| 'colorShadowLayoutToggle'
Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced this token with colorBorderLayout rendering the same look

@jperals
Copy link
Member

jperals commented Jul 20, 2023

Before this change the focus rings in Classic didn't look right, they were cut off:

Screenshot 2023-07-20 at 10 24 02

After this change they are shown inside the corresponding toggle button, which gets rid of this particular problem, but there are still a couple things that I think could be improved:

  1. They have some margin to the container horizontally but stick to the border vertically:

Screenshot 2023-07-20 at 10 22 40

  1. Maybe more importantly, they are hard to distinguish over the currently active item:

Screenshot 2023-07-20 at 10 14 44

I see two possible ways to fix this:

  1. Fine tune the dimensions to have some margin both horizontally and vertically, and use the bright variant of the focus ring color for the currently active item

  2. Bring the focus ring back to be outside of the drawer toggle buttons, fixing the cutoff issue. As a quick experiment, by removing overflow: auto from the drawer-content they look like this:

Screenshot 2023-07-20 at 10 16 38

@just-boris
Copy link
Member Author

I knew about this issue and I will fix it in the next iteration. The current state is not a regression comparing to before

@just-boris
Copy link
Member Author

The plan is to reuse this treatment from calendar

image

@just-boris just-boris merged commit 5881b58 into main Jul 20, 2023
23 checks passed
@just-boris just-boris deleted the fix-classic-drawers branch July 20, 2023 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants