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(CustomSelect): auto scroll only on open #8173

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

BlackySoul
Copy link
Contributor

Описание

Дано - селект, в который по какому-то условию подгружаются опции (например, когда долистали до конца списка).
В чем проблема? Сейчас мы делаем скролл к выбранной опции внутри ref-callback, который в deps имеет фунцию, которая зависит от options.length, соответственно ref-callback вызывается каждый раз, как меняется количество опций и происходит скролл к выбранному элементу.

Изменения

Оставляем ref-callback без зависимостей и уносим из него установку скролла (ещё это потенциально улучшит потребление памяти).
Установку скролла делаем в useIsomorphicLayoutEffect, ориентируясь на ref-переменную scrollPerformedRef.

Release notes

  • CustomSelect: исправлен нежелательный скролл до элемента при открытом выпадающем окне

@BlackySoul BlackySoul added this to the v7.2.0 milestone Jan 22, 2025
@BlackySoul BlackySoul self-assigned this Jan 22, 2025
@BlackySoul BlackySoul requested a review from a team as a code owner January 22, 2025 13:44
@github-actions github-actions bot added the patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча label Jan 22, 2025
Copy link
Contributor

github-actions bot commented Jan 22, 2025

size-limit report 📦

Path Size
JS 392.42 KB (+0.03% 🔺)
JS (gzip) 119.02 KB (+0.02% 🔺)
JS (brotli) 98.05 KB (+0.22% 🔺)
JS import Div (tree shaking) 1.56 KB (0%)
CSS 344.03 KB (0%)
CSS (gzip) 42.64 KB (0%)
CSS (brotli) 34.01 KB (0%)

Copy link

codesandbox-ci bot commented Jan 22, 2025

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

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.49%. Comparing base (9205131) to head (9c59ac6).
Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8173   +/-   ##
=======================================
  Coverage   95.49%   95.49%           
=======================================
  Files         403      403           
  Lines       11456    11462    +6     
  Branches     3781     3784    +3     
=======================================
+ Hits        10940    10946    +6     
  Misses        516      516           
Flag Coverage Δ
unittests 95.49% <100.00%> (+<0.01%) ⬆️

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.

@BlackySoul BlackySoul force-pushed the blackysoul/fix_customselect_auto_scroll branch from 5d4e0d5 to 9c59ac6 Compare January 23, 2025 05:34
Copy link
Contributor

e2e tests

Playwright Report

Copy link
Contributor

👀 Docs deployed

Commit 9c59ac6

@BlackySoul BlackySoul removed the patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча label Jan 24, 2025
@BlackySoul BlackySoul merged commit b3f1bc9 into master Jan 24, 2025
29 checks passed
@BlackySoul BlackySoul deleted the blackysoul/fix_customselect_auto_scroll branch January 24, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants