-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Popover): add anchorRef prop #7113
base: master
Are you sure you want to change the base?
feat(Popover): add anchorRef prop #7113
Conversation
size-limit report 📦
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
e2e tests
|
👀 Docs deployed
Commit cfcbff4 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7113 +/- ##
==========================================
- Coverage 95.17% 95.15% -0.02%
==========================================
Files 384 386 +2
Lines 11212 11269 +57
Branches 3674 3697 +23
==========================================
+ Hits 10671 10723 +52
- Misses 541 546 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
); | ||
|
||
useIsomorphicLayoutEffect(() => { | ||
if (anchorRef) { | ||
refs.setReference('current' in anchorRef ? anchorRef.current : anchorRef); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай добавим на этот кейс тест
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется данный кейс сложно протестить, из-за того, что позиционирование происходит с помощью библиотеки. Или может есть способ проще?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно будет в тесте:
- использовать проп
anchorRef
иdefaultShown={false}
; - тыкнуть на элемент, на котором
anchorRef
; - проверить, что
Popover
открылся
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Либо ты, любо я неправильно поняли задачу. anchorRef это элемент относительно которого будет позиционироваться поповер. При этом открываться поповер будет при клике на children как раньше. По крайней мере я так понял задачу
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Аааа интерестинг, я действительно понял так, что anchotRef
заменяет целевой элемент из children
@MrZillaGold подскажи плиз по поведению anchotRef
– он должен на себя перенять события или должен быть чисто как элемент, рядом с которым будет отрисовываться Popover
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет! Должен перенимать события тоже, потому что при передаче anchorRef, children передаваться не будет, следовательно на что-то реагировать при клике нужно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Понял, значит я не так понял)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Разбил компонент Popover на два: PopoverWithChildren, PopoverWithAnchor. Один для отображения с children, другой для отображения с anchorRef. Добавил необходимые подписки и установки aria атрибутов в кейс с использованием anchorRef.
# Conflicts: # packages/vkui/src/components/Popover/Popover.tsx
# Conflicts: # packages/vkui/src/components/CustomSelect/__image_snapshots__/customselect-scroll-to-option-android-chromium-light-1-snap.png
Описание
Нужно добавить пропс для компонента Popover с помощью которого можно указать элемент, относительно которого будет позиционироваться поповер
Изменения
Добавил пропс anchorRef в компонент Popover. При передаче его, поповер будет позиционироваться относительно указанного элемента