Skip to content

Commit

Permalink
fix(a11y): Prevent horizontal scroll on smaller screens (#19205)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrozdsap authored Oct 1, 2024
1 parent 6d1526e commit ed6700b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class AddedToCartDialogComponent implements OnInit, OnDestroy {
protected el: ElementRef
) {
useFeatureStyles('a11yExpandedFocusIndicator');
useFeatureStyles('a11yPreventHorizontalScroll');
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import {
SelectiveCartFacade,
CartOutlets,
} from '@spartacus/cart/base/root';
import { FeatureConfigService, UserIdService } from '@spartacus/core';
import {
FeatureConfigService,
UserIdService,
useFeatureStyles,
} from '@spartacus/core';
import { OutletContextData } from '@spartacus/storefront';
import { Observable, Subscription } from 'rxjs';
import { map, startWith, tap } from 'rxjs/operators';
Expand Down Expand Up @@ -93,7 +97,9 @@ export class CartItemListComponent implements OnInit, OnDestroy {
protected multiCartService: MultiCartFacade,
protected cd: ChangeDetectorRef,
@Optional() protected outlet?: OutletContextData<ItemListContext>
) {}
) {
useFeatureStyles('a11yPreventHorizontalScroll');
}

ngOnInit(): void {
this.subscription.add(this.getInputsFromContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
}
}

@include forFeature('a11yPreventHorizontalScroll') {
.cx-quantity {
@include media-breakpoint-down(xs) {
flex-direction: column;
align-items: start;
gap: 5px;
}
}
}

.cx-actions {
justify-content: flex-start;
}
Expand Down
4 changes: 4 additions & 0 deletions feature-libs/cart/base/styles/components/_cart-item-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
.cx-code {
color: var(--cx-color-secondary);
margin-top: 0.5em;

@include forFeature('a11yPreventHorizontalScroll') {
overflow-wrap: anywhere;
}
}

.cx-link {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class AddToSavedCartComponent implements OnInit, OnDestroy {
protected launchDialogService: LaunchDialogService
) {
useFeatureStyles('a11yExpandedFocusIndicator');
useFeatureStyles('a11yUseButtonsForBtnLinks');
}

ngOnInit(): void {
Expand Down
6 changes: 6 additions & 0 deletions feature-libs/cart/saved-cart/styles/_add-to-saved-cart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ cx-add-to-saved-cart {
.cx-action-link {
&:nth-child(n + 2) {
margin-inline-end: 0;

@include forFeature('a11yUseButtonsForBtnLinks') {
display: flex;
align-items: start;
}

&:before {
content: '|';
@include forFeature('a11yExpandedFocusIndicator') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ export interface FeatureTogglesInterface {
*/
a11yViewChangeAssistiveMessage?: boolean;

/**
* Prevent horizontal scroll appearing on smaller screens for `CartItemListComponent`, `AddedToCartDialogComponent`
*/
a11yPreventHorizontalScroll?: boolean;

/**
* Refocuses inside of 'ReorderDialogComponent' after its content updates.
*/
Expand Down Expand Up @@ -626,6 +631,7 @@ export const defaultFeatureToggles: Required<FeatureTogglesInterface> = {
a11yOrderConfirmationHeadingOrder: false,
a11yStarRating: false,
a11yViewChangeAssistiveMessage: false,
a11yPreventHorizontalScroll: false,
a11yReorderDialog: false,
a11yPopoverFocus: false,
a11yScheduleReplenishment: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ if (environment.cpq) {
a11yOrderConfirmationHeadingOrder: true,
a11yStarRating: true,
a11yViewChangeAssistiveMessage: true,
a11yPreventHorizontalScroll: true,
a11yReorderDialog: true,
a11yPopoverFocus: true,
a11yScheduleReplenishment: true,
Expand Down

0 comments on commit ed6700b

Please sign in to comment.