-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(useFloatingWithInteractions): extend API (#6166)
<!-- Чеклист. Лишние пункты можно удалить если изменения не подразумевают их наличие. Иначе, необходимо обоснование по каждому пункту. --> - [x] Unit-тесты h2. Описание - Для `onShownChange` добавляем второй аргумент `reason`, чтобы у пользователя появилась возможность закрывать/открывать всплывающий в зависимости от причины. Создаём тип `OnShownChange`. - Явно объявляем результат работы хука `UseFloatingWithInteractionsReturn`. - Удаляем неиспользуемый тип `content` из параметров. - Добавляем метод `onClose()`, чтобы была возможность программно закрыть всплывающий элемент. Это новый тип в `ShownChangeReason` `'callback'`. У пользователя будет возможность прокинуть метод куда-то в дочерний элемент и т.п.. h2. Изменения 1. Обмазал все `expect` хелпером [`waitFor`](https://testing-library.com/docs/dom-testing-library/api-async/#waitfor) – она позволяет дождаться выполнения `setTimeout(fn, 0)`. 2. За счёт п.1 получилось убрать в `FocusTrap` хак для тестов. https://github.com/VKCOM/VKUI/blob/b15b2451d463d202e76f035de2e360ef7b43befb/packages/vkui/src/components/FocusTrap/FocusTrap.tsx#L112-L116 3. То, что не покрыть тестами заигнорил через `/* istanbul ignore <word>[non-word] [optional-docs] */` (см. [доку](https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md))
- Loading branch information
Showing
7 changed files
with
376 additions
and
125 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
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
6 changes: 5 additions & 1 deletion
6
packages/vkui/src/lib/floating/useFloatingWithInteractions/index.ts
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,5 +1,9 @@ | ||
export { useFloatingWithInteractions } from './useFloatingWithInteractions'; | ||
|
||
export type { UseFloatingWithInteractionsProps } from './types'; | ||
export type { | ||
OnShownChange, | ||
UseFloatingWithInteractionsProps, | ||
UseFloatingWithInteractionsReturn, | ||
} from './types'; | ||
|
||
export { DEFAULT_TRIGGER } from './constants'; |
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
Oops, something went wrong.