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(ImageBaseOverlay): fix nested Tappable #7006

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

BlackySoul
Copy link
Contributor

@BlackySoul BlackySoul commented Jun 10, 2024


  • Unit-тесты
  • Документация фичи (?)

Описание

by design вложенные Tappable ресетят hover/active-состояние верхнеуровневого Tappable, чтобы поддержать следующее поведение (актуально только для 2-х уровневой вложенности, это оке?):

2024-06-11.00.58.07.mov

В случае с ImageBaseOverlay такое поведение нежелательно.

Изменения

Добавила DisableClickableLockStateContext для отключения такого поведения (принимаю в пожертвование лучшее название).
Сначала думала сделать это через проп на Tappable, но, кажется, что DX такого решения будет сомнительный. Например, в случае с ImageBaseOverlay мы точно знаем, что дефолтное поведение не нужно, но будем заставлять пользователя в каждую кнопку прокидывать проп 🤔

Изменения v2

В текущей версии компонента некорректно передавать в overlay интерактивные элементы, потому что получается кнопка в кнопке.

В новой реализации убрала использование Tappable - кажется, это не breaking change, потому что мы никакие пропы, специфичные для Tappable не прокидывали - по сути он нам нужен только для hover-эффекта (остальное мы либо отключаем, либо не можем отключить, но оно мешает - например, меняется вид поинтера). В итоге получился интерактивный и неинтерактивный компоненты, принимаем решение, какой из них рисовать, на основе нового пропа nonInteractive - в таске предлагали завязываться на onClick, но такое мы не можем провернуть - потому что сейчас поведение по-умолчанию - если onClick не передан, то мы подставляем noop и hover-эффект работает из коробки (кому-то можем сломать это поведение).

@BlackySoul BlackySoul requested a review from a team as a code owner June 10, 2024 18:06
@github-actions github-actions bot added the patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча label Jun 10, 2024
Copy link
Contributor

github-actions bot commented Jun 10, 2024

size-limit report 📦

Path Size
JS 365.96 KB (+0.27% 🔺)
JS (gzip) 112.06 KB (+0.27% 🔺)
JS (brotli) 92.28 KB (+0.18% 🔺)
JS import Div (tree shaking) 1.42 KB (0%)
CSS 286.59 KB (+0.02% 🔺)
CSS (gzip) 37.19 KB (+0.02% 🔺)
CSS (brotli) 30.08 KB (+0.12% 🔺)

Copy link

codesandbox-ci bot commented Jun 10, 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 Jun 10, 2024

e2e tests

Playwright Report

Copy link
Contributor

github-actions bot commented Jun 10, 2024

👀 Docs deployed

Commit 72d4bcf

Copy link

codecov bot commented Jun 10, 2024

Codecov Report

Attention: Patch coverage is 93.10345% with 4 lines in your changes missing coverage. Please review.

Project coverage is 83.65%. Comparing base (0f7194b) to head (72d4bcf).
Report is 30 commits behind head on master.

Files Patch % Lines
...src/components/ImageBase/ImageBaseOverlay/hooks.ts 81.81% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7006      +/-   ##
==========================================
+ Coverage   83.49%   83.65%   +0.16%     
==========================================
  Files         351      352       +1     
  Lines       10501    10575      +74     
  Branches     3477     3501      +24     
==========================================
+ Hits         8768     8847      +79     
+ Misses       1733     1728       -5     
Flag Coverage Δ
unittests 83.65% <93.10%> (+0.16%) ⬆️

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 previously approved these changes Jun 11, 2024
Copy link
Contributor

@mendrew mendrew left a comment

Choose a reason for hiding this comment

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

💅

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.

@inomdzhon inomdzhon marked this pull request as draft June 11, 2024 14:29
@vkcom-publisher vkcom-publisher added pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Jun 19, 2024
@BlackySoul BlackySoul force-pushed the fix/7001/ImageBase.overlay_fix_nested_tappable branch from 737557d to 7ac884e Compare June 26, 2024 07:05
@BlackySoul BlackySoul marked this pull request as ready for review June 26, 2024 07:35
mendrew
mendrew previously approved these changes Jun 27, 2024
Copy link
Contributor

@mendrew mendrew left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Co-authored-by: Andrey Medvedev <[email protected]>
@BlackySoul BlackySoul requested a review from mendrew June 27, 2024 08:25
@inomdzhon inomdzhon removed the patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча label Jun 27, 2024
* > использовали иконку.
*/
children: React.ReactElement<ImageBaseExpectedIconProps>;
nonInteractive?: false;
Copy link
Contributor

Choose a reason for hiding this comment

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

а можем на disableInteractive переименовать? 👉 👈 у нас сейчас в FloatingComponentProps так называется

только на уровне внешнего API, хук useNonInteractiveOverlayProps можно так и оставить

Copy link
Contributor

Choose a reason for hiding this comment

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

только вот юниты придётся удалить на добавление класса...

};
}

export function useHover() {
Copy link
Contributor

Choose a reason for hiding this comment

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

можем при on-hover в CSS перенести на @media (--hover-has)?

overlayShown: visibility === 'always' || (visibility === 'on-hover' && hovered),
};

if (restProps.nonInteractive) {
Copy link
Contributor

Choose a reason for hiding this comment

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

вижу nonInteractive не нужон в ImageBaseOverlayNonInteractive и ImageBaseOverlayInteractive, можно вытащить из пропсов, а в типах ImageBaseOverlayNonInteractive и ImageBaseOverlayInteractive исключить проп через Omit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants