Skip to content
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

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

EldarMuhamethanov
Copy link
Contributor


  • Документация фичи

Описание

Нужно добавить пропс для компонента Popover с помощью которого можно указать элемент, относительно которого будет позиционироваться поповер

Изменения

Добавил пропс anchorRef в компонент Popover. При передаче его, поповер будет позиционироваться относительно указанного элемента

@EldarMuhamethanov EldarMuhamethanov requested a review from a team as a code owner July 1, 2024 13:50
Copy link
Contributor

github-actions bot commented Jul 1, 2024

size-limit report 📦

Path Size
JS 381.86 KB (+0.31% 🔺)
JS (gzip) 115.6 KB (+0.29% 🔺)
JS (brotli) 94.91 KB (+0.34% 🔺)
JS import Div (tree shaking) 1.45 KB (0%)
CSS 309.06 KB (0%)
CSS (gzip) 39.64 KB (0%)
CSS (brotli) 31.86 KB (0%)

Copy link

codesandbox-ci bot commented Jul 1, 2024

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.

Copy link
Contributor

github-actions bot commented Jul 1, 2024

e2e tests

⚠️ Some screenshots were failed. See Playwright Report.

Playwright Report

Copy link
Contributor

github-actions bot commented Jul 1, 2024

👀 Docs deployed

Commit cfcbff4

Copy link

codecov bot commented Jul 1, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 95.15%. Comparing base (7a9018e) to head (cfcbff4).
Report is 84 commits behind head on master.

Files with missing lines Patch % Lines
.../vkui/src/components/Popover/PopoverWithAnchor.tsx 90.90% 4 Missing ⚠️
packages/vkui/src/components/Popover/Popover.tsx 85.71% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 95.15% <91.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

SevereCloud
SevereCloud previously approved these changes Jul 1, 2024
);

useIsomorphicLayoutEffect(() => {
if (anchorRef) {
refs.setReference('current' in anchorRef ? anchorRef.current : anchorRef);
Copy link
Contributor

Choose a reason for hiding this comment

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

давай добавим на этот кейс тест

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Мне кажется данный кейс сложно протестить, из-за того, что позиционирование происходит с помощью библиотеки. Или может есть способ проще?

Copy link
Contributor

Choose a reason for hiding this comment

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

Нужно будет в тесте:

  1. использовать проп anchorRef и defaultShown={false};
  2. тыкнуть на элемент, на котором anchorRef;
  3. проверить, что Popover открылся

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Либо ты, любо я неправильно поняли задачу. anchorRef это элемент относительно которого будет позиционироваться поповер. При этом открываться поповер будет при клике на children как раньше. По крайней мере я так понял задачу

Copy link
Contributor

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?

Copy link
Contributor

@MrZillaGold MrZillaGold Jul 6, 2024

Choose a reason for hiding this comment

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

Привет! Должен перенимать события тоже, потому что при передаче anchorRef, children передаваться не будет, следовательно на что-то реагировать при клике нужно

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Понял, значит я не так понял)

Copy link
Contributor Author

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.

@EldarMuhamethanov EldarMuhamethanov marked this pull request as draft July 8, 2024 07:08
# Conflicts:
#	packages/vkui/src/components/Popover/Popover.tsx
@EldarMuhamethanov EldarMuhamethanov marked this pull request as ready for review July 8, 2024 15:34
# Conflicts:
#	packages/vkui/src/components/CustomSelect/__image_snapshots__/customselect-scroll-to-option-android-chromium-light-1-snap.png
@inomdzhon inomdzhon marked this pull request as draft July 16, 2024 16:37
@vkcom-publisher vkcom-publisher added pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Jul 24, 2024
@vkcom-publisher vkcom-publisher added pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Aug 2, 2024
@vkcom-publisher vkcom-publisher added pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Aug 12, 2024
@vkcom-publisher vkcom-publisher added pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Aug 27, 2024
@vkcom-publisher vkcom-publisher added pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Sep 10, 2024
@vkcom-publisher vkcom-publisher added the pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature][Popover]: Возможность установки своего ref извне
5 participants