-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AccordionContent): refactor for useCSSKeyframesAnimationControlle…
…r() (#7083) Чтобы не зашивать `max-height`, устанавливаем его тогда, когда нужно (с переходом с `transition` на `animation` заменил на использование `height`). Сделал для удобства, через CSS переменную, которую добавляем/удалям в `useLayoutEffect()` относительно `animationState`. По умолчанию, переменная со значением `initial`. Для `@media (--reduce-motion)` заменяем анимацию на `opacity`.
- Loading branch information
Showing
5 changed files
with
156 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { baselineComponent } from '../../testing/utils'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { baselineComponent, waitCSSKeyframesAnimation } from '../../testing/utils'; | ||
import { Accordion } from './Accordion'; | ||
|
||
describe(Accordion, () => { | ||
baselineComponent(Accordion.Content); | ||
baselineComponent(Accordion.Summary, { a11y: false }); | ||
|
||
it('toggles on click', () => { | ||
render( | ||
it('toggles on click', async () => { | ||
const result = render( | ||
<Accordion> | ||
<Accordion.Summary iconPosition="before" data-testid="summary"> | ||
Title | ||
</Accordion.Summary> | ||
<Accordion.Content data-testid="content">Content</Accordion.Content> | ||
</Accordion>, | ||
); | ||
const content = screen.getByTestId<HTMLDivElement>('content'); | ||
const summary = screen.getByTestId('summary'); | ||
const content = result.getByTestId('content'); | ||
const contentIn = content.firstElementChild as HTMLElement; | ||
const summary = result.getByTestId('summary'); | ||
expect(content.getAttribute('aria-hidden')).toBe('true'); | ||
|
||
fireEvent.click(summary); | ||
await waitCSSKeyframesAnimation(contentIn); | ||
expect(content.getAttribute('aria-hidden')).toBe('false'); | ||
|
||
fireEvent.click(summary); | ||
await waitCSSKeyframesAnimation(contentIn); | ||
expect(content.getAttribute('aria-hidden')).toBe('true'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters