Skip to content

fix: fix searchbox carousel navigation behaviour#21141

Merged
c5346163 merged 39 commits intodevelopfrom
CXCDS-17219
Mar 12, 2026
Merged

fix: fix searchbox carousel navigation behaviour#21141
c5346163 merged 39 commits intodevelopfrom
CXCDS-17219

Conversation

@c5346163
Copy link
Copy Markdown
Contributor

@c5346163 c5346163 commented Feb 10, 2026

Fix Safari searchbox carousel clicks closing results panel by preventing mousedown blur and moving next-slide logic into a reusable handler.

@c5346163 c5346163 requested a review from a team as a code owner February 10, 2026 11:42
@github-actions github-actions Bot marked this pull request as draft February 10, 2026 11:42
@c5346163 c5346163 marked this pull request as ready for review February 10, 2026 11:43
@github-actions github-actions Bot marked this pull request as draft February 10, 2026 11:43
@c5346163 c5346163 marked this pull request as ready for review February 10, 2026 11:44
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@cypress
Copy link
Copy Markdown

cypress Bot commented Feb 10, 2026

spartacus    Run #52253

Run Properties:  status check passed Passed #52253  •  git commit 4cc399eddb ℹ️: Merge 8c6d5510a114fc0b067cac7dd70bc7edafb4c445 into b1f12daaa996f3cd51a0a83977ac...
Project spartacus
Branch Review CXCDS-17219
Run status status check passed Passed #52253
Run duration 03m 24s
Commit git commit 4cc399eddb ℹ️: Merge 8c6d5510a114fc0b067cac7dd70bc7edafb4c445 into b1f12daaa996f3cd51a0a83977ac...
Committer Konrad Dzikowski
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 101
View all changes introduced in this branch ↗︎

@c5346163 c5346163 requested a review from rmch91 February 10, 2026 12:12
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot marked this pull request as draft February 10, 2026 12:58
@c5346163 c5346163 marked this pull request as ready for review February 10, 2026 14:19
@github-actions github-actions Bot marked this pull request as draft February 10, 2026 19:24
@c5346163 c5346163 marked this pull request as ready for review February 12, 2026 07:57
Pucek9
Pucek9 previously approved these changes Feb 12, 2026
Copy link
Copy Markdown
Contributor

@Pucek9 Pucek9 left a comment

Choose a reason for hiding this comment

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

LGTM

QA steps I did:
On Mac, opened the homepage and decreased the window height, typed "cam" in searchbox and saw carousel arrows; both work fine and no longer close the search results
image

rmch91
rmch91 previously requested changes Feb 12, 2026
[template]="carouselItem"
itemWidth="160px"
(keybordEvent)="carouselEventPropagator($event)"
(mousedown)="preventDefault($event)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually this can be breaking change for customers, example:
Customer registered event listener, something like: this.el.nativeElement.addEventListener('focus', this.onFocus, true); and implement some custom logic on focus.
When you are adding (mousedown)="preventDefault($event)" it will not be triggered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rmch91 That's true, but the question that comes to mind is why would he do it in such a complicated way? If he extends the class, that forces him to have its own HTML structure (which will not be automatically updated from here). The fact that we cannot fix the behavior in his code - it's beyond our control if there is any customization, the question is only whether we are able to break something in his code/ui behavior this way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

User can do it without any customization of the component. just register an event listener on cx-carousel in app.component and apply his own logic.
After this change it will not work. So seems that it is breaking

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've made the fix opt-in via a preventNavigationFocus input flag (defaults to false), so it's only enabled in search-box and doesn't affect existing carousels or customer event listeners.

@github-actions github-actions Bot marked this pull request as draft February 13, 2026 14:31
@c5346163 c5346163 marked this pull request as ready for review February 13, 2026 14:56
@c5346163 c5346163 requested review from Pucek9 and rmch91 February 13, 2026 15:21
@github-actions github-actions Bot marked this pull request as draft February 18, 2026 11:43
@github-actions github-actions Bot marked this pull request as draft March 11, 2026 10:32
@c5346163 c5346163 marked this pull request as ready for review March 11, 2026 11:03
@github-actions github-actions Bot marked this pull request as draft March 11, 2026 12:17
@c5346163 c5346163 marked this pull request as ready for review March 11, 2026 12:21
a11yFacetFilterByLabel: false,
removeDuplicatedOrderHistoryHeader: false,
a11yCardNotificationMessage: false,
a11yCarouselPreventNavigationFocus: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As far as I know, for the introduction of toggles to make sense, they should be introduced with a false value. Some time after their introduction, they remain in place: first, they are changed to true, then, before the release of the next major version, the flags and legacy code are cleared.

Suggested change
a11yCarouselPreventNavigationFocus: true,
a11yCarouselPreventNavigationFocus: false,

<button
*cxFeature="'!a11yCarouselPreventNavigationFocus'"
class="previous"
(click)="onPreviousClick($event, size)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Old block should remain unchanged

Suggested change
(click)="onPreviousClick($event, size)"
(click)="
$event.stopPropagation();
activeSlide === 0 ? null : (activeSlide = activeSlide - size)
"

<button
*cxFeature="'!a11yCarouselPreventNavigationFocus'"
class="next"
(click)="onNextClick($event, size)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here as well

Suggested change
(click)="onNextClick($event, size)"
(click)="
$event.stopPropagation();
activeSlide > items.length - size - 1
? null
: (activeSlide = activeSlide + size)
"

* unwanted blur events (e.g., in Safari when carousel is used inside modals or search boxes).
* Defaults to false to maintain backward compatibility.
*/
@Input() preventNavigationFocus = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of input, you can move inject and logic from parent component here

@github-actions github-actions Bot marked this pull request as draft March 11, 2026 13:09
@c5346163 c5346163 marked this pull request as ready for review March 11, 2026 13:11
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions Bot marked this pull request as draft March 11, 2026 13:32
@c5346163 c5346163 marked this pull request as ready for review March 11, 2026 13:34
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions Bot marked this pull request as draft March 11, 2026 13:39
@c5346163 c5346163 marked this pull request as ready for review March 11, 2026 13:41
@c5346163 c5346163 requested a review from Pucek9 March 11, 2026 13:54
…-17219

# Conflicts:
#	projects/storefrontlib/shared/components/carousel/carousel.component.spec.ts
@github-actions github-actions Bot marked this pull request as draft March 12, 2026 10:42
@c5346163 c5346163 marked this pull request as ready for review March 12, 2026 10:48
* that contain or interact with the carousel, since preventing mousedown default can affect focus behavior.
* Affects: `CarouselComponent` (when preventNavigationFocus input is true, e.g. in SearchBoxComponent)
*/
a11yCarouselPreventNavigationFocus?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it really a11y related flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Focus management and predictable keyboard navigation are core a11y concerns, so gating this Safari-specific focus fix behind an a11y* flag is reasonable.

Copy link
Copy Markdown
Contributor

@Pucek9 Pucek9 left a comment

Choose a reason for hiding this comment

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

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.

4 participants