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: Prevent dragging options in Collection preferences from causing page overflow #1072

Merged
merged 12 commits into from
May 9, 2023

Conversation

jperals
Copy link
Member

@jperals jperals commented May 8, 2023

Description

This change fixes 3 things:

1. Page overflow

The unintended behavior depicted in the video below, where dragging an item beyond the right or bottom edge of the browser window would cause overflow:

Screen.Recording.2023-04-18.at.09.38.55.mov

This had been identified previously as a high-priority post-release item, and also reported in #804 (comment) (where the video above is taken from).

This has been fixed by using a drag overlay, which is anyway the recommended way to implement dragging with dnd-kit: https://docs.dndkit.com/api-documentation/draggable/drag-overlay. In this approach, the active item (the one being dragged) is rendered in a portal and a placeholder (blue rectangle) is rendered in its place in the list. The fact that the active item is rendered outside of the modal, and therefore it doesn't have scrollable ancestors anymore, fixes the overflow issue.

2. Border radius of the focus ring

This PR also fixes the border-radius of the focus ring for the active item to use the border-radius-item design token (change reviewed by design).

Before (border radius too small in Visual Refresh, not corresponding to the border radius of the item itself):
Screenshot 2023-05-08 at 18 17 28

After (expected border radius of 8px in Visual Refresh):
Screenshot 2023-05-08 at 18 17 47

3. Word wrapping in the option labels

In extreme cases where the label text is a single word longer than the space available, break the word.

Before:
Screenshot 2023-05-09 at 09 04 01

After:
Screenshot 2023-05-09 at 09 03 45

How has this been tested?

  • Added integration tests to cover issue 1
  • Issues 2 and 3 are covered by existing visual regression tests
  • Manually tested in Chrome, Firefox and Safari
  • Manually tested Chrome + VoiceOver
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 May 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (78d0b88) 92.81% compared to head (7a609f5) 92.82%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1072   +/-   ##
=======================================
  Coverage   92.81%   92.82%           
=======================================
  Files         606      607    +1     
  Lines       15914    15913    -1     
  Branches     5135     5131    -4     
=======================================
  Hits        14771    14771           
+ Misses       1065     1064    -1     
  Partials       78       78           
Impacted Files Coverage Δ
...erences/content-display/content-display-option.tsx 100.00% <100.00%> (ø)
...n-preferences/content-display/draggable-option.tsx 100.00% <100.00%> (ø)
...c/collection-preferences/content-display/index.tsx 100.00% <100.00%> (ø)
...llection-preferences/content-display-preference.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.

@@ -21,60 +21,54 @@ $border-radius: awsui.$border-radius-item;
}
}

.sortable-item-toggle {
.content-display-option-toggle {
Copy link
Member Author

Choose a reason for hiding this comment

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

Harmonized internal names with testing utils API: "sortable item" is now "content display option".

const componentPrefix = 'content-display-option';
export const getClassName = (suffix?: string) => styles[[componentPrefix, suffix].filter(Boolean).join('-')];

export interface ContentDisplayOptionProps {
Copy link
Member Author

Choose a reason for hiding this comment

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

Following the "presentational component" pattern as documented in the dnd-kit documentation, this component is used in two ways:

  • For the options displayed in the list, wrapped in DraggableOption
  • While dragging, to render the active (i.e, dragged) item wrapped in the DragOverlay

box-shadow: awsui.$shadow-container-active;
border-radius: $border-radius;
@include focus-visible {
@include styles.focus-highlight(0px, $border-radius);
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 second parameter $border-radius was previously missing; this fixes the focus ring border radius.

flex-grow: 1;
@include styles.text-wrapping;
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes the word wrapping in the option label.

@jperals jperals marked this pull request as ready for review May 9, 2023 07:44
@jperals jperals requested a review from a team as a code owner May 9, 2023 07:44
@jperals jperals requested review from pan-kot and removed request for a team May 9, 2023 07:44
pan-kot
pan-kot previously approved these changes May 9, 2023
@@ -64,6 +69,43 @@ describe('Collection preferences - Content Display preference', () => {
await expect(wrapper.findModal()).not.toBeNull();
})
);

describe('does not cause overflow when reaching the edge of the window', () => {
const wait = (delay: number) => new Promise(resolve => setTimeout(resolve, delay));
Copy link
Member

Choose a reason for hiding this comment

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

Can we use page.pause() instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

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