Skip to content

Commit

Permalink
(PC-33528)[PRO] feat: handle scroll and focus when multiselect has error
Browse files Browse the repository at this point in the history
  • Loading branch information
ahello-pass committed Jan 21, 2025
1 parent ebec9fe commit af365e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { useEffect } from 'react'
import { doesUserPreferReducedMotion } from 'commons/utils/windowMatchMedia'

const scrollToFirstError = () => {
const firstErrorElement = document.querySelector<
HTMLInputElement | HTMLElement
>('[aria-invalid="true"]')
const firstErrorElement =
document.querySelector<HTMLInputElement | HTMLElement>(
'[aria-invalid="true"]'
) ?? document.querySelector<HTMLElement>('[data-error="true"]')

const scrollBehavior = doesUserPreferReducedMotion() ? 'auto' : 'smooth'

// Without the setTimeout, the smooth behavior isn't working
Expand Down
1 change: 1 addition & 0 deletions pro/src/ui-kit/MultiSelect/MultiSelectTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const MultiSelectTrigger = ({
aria-expanded={isOpen}
aria-controls={id}
disabled={disabled}
data-error={!!error}
>
<div className={styles['trigger-content']}>
{selectedCount > 0 && (
Expand Down

0 comments on commit af365e6

Please sign in to comment.