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

fix(useFloatingWithInteractions): improve restoreFocus, add restoreFocus to anchor element #7806

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

EldarMuhamethanov
Copy link
Contributor

@EldarMuhamethanov EldarMuhamethanov commented Oct 22, 2024


  • Unit-тесты
  • Release notes

Описание

Нужно добавить возможность настройки элемента, куда будет возвращаться фокус после закрытия поповера по ховеру.

Изменения

В Popover и Tooltip расширил тип свойства restoreFocus. Теперь помимо boolean он может принимать следующие значения:

  • true - означает, что фокус будет возвращен на последний активный до открытия всплывающего окна элемент. По сути это поведение по умолчанию
  • 'anchor-element' - означает, что фокус будет возвращен на якорный элемент
  • HTMLElement - можно использовать ссылку на определенный html элемент

Также изменения затронули компонент FocusTrap:

  • Теперь в свойство restoreFocus можно прокинуть, помимо функции, возвращающей boolean, функцию, возвращающую HTMLElement(() => boolean | HTMLElement).

Теперь, чтобы поправить баг описанный в задаче необходимо для Popover с trigger="hover" прокинуть restoreFocus="anchor-element"

Release notes

Улучшения

  • Popover: расширен тип свойства restoreFocus до boolean | 'anchor-element' | HTMLElement для указания на какой элемент будет возвращен фокус после закрытия Popover. Полезно для кейса с Popover с trigger="hover", при установке restoreFocus="anchor-element" фокус всегда будет возвращаться в якорный элемент

@EldarMuhamethanov EldarMuhamethanov requested a review from a team as a code owner October 22, 2024 08:02
Copy link
Contributor

github-actions bot commented Oct 22, 2024

size-limit report 📦

Path Size
JS 385.42 KB (+0.07% 🔺)
JS (gzip) 123.21 KB (+0.09% 🔺)
JS (brotli) 102.08 KB (+0.07% 🔺)
JS import Div (tree shaking) 1.47 KB (0%)
CSS 342.28 KB (0%)
CSS (gzip) 49.35 KB (0%)
CSS (brotli) 40 KB (0%)

Copy link

codesandbox-ci bot commented Oct 22, 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 Oct 22, 2024

e2e tests

Playwright Report

Copy link
Contributor

github-actions bot commented Oct 22, 2024

👀 Docs deployed

Commit c07f29c

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 87.23404% with 6 lines in your changes missing coverage. Please review.

Project coverage is 95.30%. Comparing base (ca09fb8) to head (c07f29c).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...ingWithInteractions/useFloatingWithInteractions.ts 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7806      +/-   ##
==========================================
- Coverage   95.34%   95.30%   -0.05%     
==========================================
  Files         378      378              
  Lines       11176    11197      +21     
  Branches     3726     3735       +9     
==========================================
+ Hits        10656    10671      +15     
- Misses        520      526       +6     
Flag Coverage Δ
unittests 95.30% <87.23%> (-0.05%) ⬇️

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.

Copy link
Contributor

@andrey-medvedev-vk andrey-medvedev-vk left a comment

Choose a reason for hiding this comment

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

👍

@inomdzhon inomdzhon added patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча v6 Автоматизация: PR продублируется в ветку v6 labels Oct 24, 2024
@vkcom-publisher vkcom-publisher added the pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности label Nov 1, 2024
@EldarMuhamethanov EldarMuhamethanov removed the pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности label Nov 2, 2024
Copy link
Contributor

@inomdzhon inomdzhon left a comment

Choose a reason for hiding this comment

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

👍

ps: в описании осталась старая инфа про latest-element

Copy link
Contributor

@andrey-medvedev-vk andrey-medvedev-vk left a comment

Choose a reason for hiding this comment

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

💅

@EldarMuhamethanov EldarMuhamethanov merged commit 3589018 into master Nov 7, 2024
26 of 28 checks passed
@EldarMuhamethanov EldarMuhamethanov deleted the e.muhamethanov/7732/improve-restore-focus branch November 7, 2024 14:38
@vkcom-publisher
Copy link
Contributor

❌ Patch

Не удалось автоматически применить исправление на ветке 7.0-stable.

Дальнейшие действия выполняют контрибьютеры из группы @VKCOM/vkui-core

Чтобы изменение попало в ветку 7.0-stable, выполните следующие действия:

  1. Создайте новую ветку от 7.0-stable и примените изменения используя cherry-pick
git stash # опционально
git fetch origin 7.0-stable
git checkout -b patch/pr7806 origin/7.0-stable

git cherry-pick --no-commit 3589018217b211293a953e717379e544b7df44ea
git checkout HEAD **/__image_snapshots__/*.png
git diff --quiet HEAD || git commit --no-verify --no-edit
  1. Исправьте конфликты, следуя инструкциям из терминала
  2. Отправьте ветку на GitHub и создайте новый PR с веткой 7.0-stable (установка лейбла не требуется!)
git push --set-upstream origin patch/pr7806
gh pr create --base 7.0-stable --title "patch: pr7806" --body "- patch #7806"

@vkcom-publisher
Copy link
Contributor

❌ Patch

Не удалось автоматически применить исправление на ветке v6.

Дальнейшие действия выполняют контрибьютеры из группы @VKCOM/vkui-core

Чтобы изменение попало в ветку v6, выполните следующие действия:

  1. Создайте новую ветку от v6 и примените изменения используя cherry-pick
git stash # опционально
git fetch origin v6
git checkout -b patch/pr7806 origin/v6

git cherry-pick --no-commit 3589018217b211293a953e717379e544b7df44ea
git checkout HEAD **/__image_snapshots__/*.png
git diff --quiet HEAD || git commit --no-verify --no-edit
  1. Исправьте конфликты, следуя инструкциям из терминала
  2. Отправьте ветку на GitHub и создайте новый PR с веткой v6 (установка лейбла не требуется!)
git push --set-upstream origin patch/pr7806
gh pr create --base v6 --title "patch: pr7806" --body "- patch #7806"

EldarMuhamethanov added a commit that referenced this pull request Nov 7, 2024
…cus to anchor element (#7806)

* fix(useFloatingWithInteractions): improve restoreFocus, add restoreFocus to anchor element

* fix(useFocusTrap): resolve conflicts

* fix: remove 'latest-active' variant from RestoreFocusType

(cherry picked from commit 3589018)
EldarMuhamethanov added a commit that referenced this pull request Nov 7, 2024
…cus to anchor element (#7806)

* fix(useFloatingWithInteractions): improve restoreFocus, add restoreFocus to anchor element

* fix(useFocusTrap): resolve conflicts

* fix: remove 'latest-active' variant from RestoreFocusType

(cherry picked from commit 3589018)
@EldarMuhamethanov EldarMuhamethanov mentioned this pull request Nov 7, 2024
EldarMuhamethanov added a commit that referenced this pull request Nov 8, 2024
…cus to anchor element (#7806) (#7914)

* fix(useFloatingWithInteractions): improve restoreFocus, add restoreFocus to anchor element

* fix(useFocusTrap): resolve conflicts

* fix: remove 'latest-active' variant from RestoreFocusType

(cherry picked from commit 3589018)
vkcom-publisher pushed a commit that referenced this pull request Nov 8, 2024
…cus to anchor element (#7806) (#7914)

* fix(useFloatingWithInteractions): improve restoreFocus, add restoreFocus to anchor element

* fix(useFocusTrap): resolve conflicts

* fix: remove 'latest-active' variant from RestoreFocusType

(cherry picked from commit 3589018)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча v6 Автоматизация: PR продублируется в ветку v6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Восстановление фокуса после закрытия Popover по 'hover'
4 participants