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(PullToRefresh): Prevent multiple calls of runRefreshing on iOS #6723

Conversation

mendrew
Copy link
Contributor

@mendrew mendrew commented Mar 19, 2024


Описание

На iOS мы вызываем runRefreshing внутри onTouchMove обработчика, который может вызываеться чаще чем обновляется состояние refreshing в стейте компонента.

if (progress > 85 && !refreshing && platform === 'ios') {
runRefreshing();
}

Это в свою очередь влечет за собой двойной вызов onRefresh.

Изменения

  • добавляем состояние вызова runRefreshing() через ref, чтобы избежать повторного вызова runRefreshing. Cбрасываем состояние в обработчике onTouchEnd().
    Это локальная проблема конкретного условия, что runRefreshing() на iOS вызывается в определённый момент ещё до конца жеста, поэтому и ref используем только в одном месте.

On iOS PullToRefresh can start refreshing earlier than
on other platforms.
We call runRefreshing() withing onTouchMove.
Since refreshing is a state variable, it can't be updated
earlier than another event of onTouchMove is called, so,
we have to user ref flag to avoid triggering runRefreshing more than
once.
@github-actions github-actions bot added the patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча label Mar 19, 2024
Copy link
Contributor

github-actions bot commented Mar 19, 2024

size-limit report 📦

Path Size
JS 356.68 KB (+0.02% 🔺)
JS (gzip) 108.86 KB (+0.02% 🔺)
JS (brotli) 89.91 KB (-0.05% 🔽)
JS import Div (tree shaking) 1.43 KB (0%)
CSS 261.66 KB (0%)
CSS (gzip) 34.27 KB (0%)
CSS (brotli) 27.79 KB (0%)

Copy link

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

e2e tests

Playwright Report

Copy link
Contributor

github-actions bot commented Mar 19, 2024

👀 Docs deployed

Commit dac4c48

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.36%. Comparing base (78e4cb5) to head (dac4c48).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6723      +/-   ##
==========================================
+ Coverage   82.35%   82.36%   +0.01%     
==========================================
  Files         335      335              
  Lines       10332    10351      +19     
  Branches     3461     3467       +6     
==========================================
+ Hits         8509     8526      +17     
- Misses       1823     1825       +2     
Flag Coverage Δ
unittests 82.36% <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.

@mendrew mendrew marked this pull request as ready for review March 19, 2024 11:43
@mendrew mendrew requested a review from a team as a code owner March 19, 2024 11:43
@mendrew mendrew modified the milestone: v6.0.2 Mar 19, 2024
@mendrew mendrew merged commit 093fde8 into master Mar 19, 2024
49 checks passed
@mendrew mendrew deleted the mendrew/6715/fix/PullToRefresh/prevent-multiple-calls-of-run-refreshing branch March 19, 2024 14:19
vkcom-publisher pushed a commit that referenced this pull request Mar 19, 2024
На iOS мы вызываем `runRefreshing` внутри `onTouchMove` обработчика, который может вызываеться чаще чем обновляется состояние refreshing в стейте компонента.
https://github.com/VKCOM/VKUI/blob/78e4cb5a5fe44fda8bbe87d079156566b2aa6ce9/packages/vkui/src/components/PullToRefresh/PullToRefresh.tsx#L222-L224

Это в свою очередь влечет за собой двойной вызов `onRefresh`.

Изменения
- добавляем состояние вызова `runRefreshing()` через ref, чтобы избежать повторного вызова `runRefreshing`. Cбрасываем состояние в обработчике onTouchEnd().
Это локальная проблема конкретного условия, что runRefreshing() на iOS вызывается в определённый момент ещё до конца жеста, поэтому и ref используем только в одном месте.
@mendrew mendrew modified the milestone: v6.0.2 Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: PullToRefresh multiple onRefresh calls
3 participants