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: Stacked notifications in compact mode and without content padding #775

Merged
merged 25 commits into from
Feb 23, 2023

Conversation

jperals
Copy link
Member

@jperals jperals commented Feb 17, 2023

Description

This PR improves the Flashbar's support for compact mode and the usage of disableContentPaddings. It does basically two things:

  • Adjusts the position of the notification bar to make sure it never overlaps notification text, especially in compact mode
  • It adds some spacing between the notifications and the main content when using disableContentPaddings and the notification bar is shown (to make sure it does not overlap the main content)

How has this been tested?

A lot of manual checking on the new page app-layout/with-stacked-notifications-and-table. Visual regression tests on this page can be done after this PR is merged. Existing visual regression tests for Flashbar are expected to fail because of small changes in the notification bar position and also because of changes in the component's bottom margin which change the screenshot area.

To manually test the changes, I suggest to visit the page app-layout/with-stacked-notifications-and-table in the deployment below and verify the following, for each combination of compact mode vs comfortable mode, and Visual Refresh vs Classic:

  • Notification bar should not overlap notification text
  • Notification bar should not overlap content below, also when disabling content paddings and also when expanded vs collapsed
  • When both notifications and table header are sticky, the table header should stick correctly to the Flashbar, without leaving any extra space between the two. (Note: in this case the notification bar does overlap the content; this is expected)
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 Feb 17, 2023

Codecov Report

Base: 93.30% // Head: 93.30% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (8f8eb5b) compared to base (896472f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #775   +/-   ##
=======================================
  Coverage   93.30%   93.30%           
=======================================
  Files         584      584           
  Lines       17123    17129    +6     
  Branches     4722     4728    +6     
=======================================
+ Hits        15976    15982    +6     
  Misses       1067     1067           
  Partials       80       80           
Impacted Files Coverage Δ
src/app-layout/index.tsx 95.06% <ø> (ø)
src/app-layout/visual-refresh/notifications.tsx 100.00% <ø> (ø)
src/app-layout/notifications/index.tsx 100.00% <100.00%> (ø)
src/flashbar/collapsible-flashbar.tsx 97.95% <100.00%> (+0.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@jperals jperals marked this pull request as ready for review February 22, 2023 12:37
@jperals jperals requested a review from a team as a code owner February 22, 2023 12:37
@jperals jperals requested review from connorlanigan and removed request for a team February 22, 2023 12:37
@@ -0,0 +1,155 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member Author

Choose a reason for hiding this comment

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

The recently added page app-layout/with-stacked-notifications-and-no-paddings was deleted in favor of this one, which is more complete and makes it redundant. No tests had been written for the former yet.

@@ -112,7 +113,7 @@ export default function CollapsibleFlashbar({ items, ...restProps }: FlashbarPro
const windowHeight = window.innerHeight;
// Take the parent region into account if using the App Layout, because it might have additional margins.
// Otherwise we use the Flashbar component for this calculation.
const outerElement = flashbar.parentElement?.parentElement || flashbar;
const outerElement = findUpUntil(flashbar, element => element.getAttribute('role') === 'region') || flashbar;
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 this more robust as I realized it was not working well on Visual Refresh (it was grabbing one level further up to the correct one). This is because the DOM structure rendered by the app layout can be different on Visual Refresh than Classic —and actually also when notifications are stick vs when they aren't.

@@ -208,6 +278,8 @@ the grid layout will be:
flex-grow: 1;
background: none;
border: 0 none;
padding-top: 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

These two lines were moved from lines 140-141 because it only needs to affect .button and not .status > .header nor .status > .item-count. See #772 for more context on what these two lines are for.

connorlanigan
connorlanigan previously approved these changes Feb 23, 2023
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