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

plasma-*: Fix Modal Overlay & Popup registration logic #1380

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

vadim-kudr
Copy link
Contributor

@vadim-kudr vadim-kudr commented Aug 21, 2024

Popup

  • исправлена логика регистрации popups

What/why changed

Сделали ошибку когда правили другой баг

фикс для PR #1325

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @salutejs/plasma-asdk@0.133.1-canary.1380.10485553077.0
npm install @salutejs/plasma-b2c@1.375.1-canary.1380.10485553077.0
npm install @salutejs/plasma-new-hope@0.128.2-canary.1380.10485553077.0
npm install @salutejs/plasma-web@1.376.1-canary.1380.10485553077.0
npm install @salutejs/sdds-cs@0.105.1-canary.1380.10485553077.0
npm install @salutejs/sdds-dfa@0.103.1-canary.1380.10485553077.0
npm install @salutejs/sdds-serv@0.104.1-canary.1380.10485553077.0
# or 
yarn add @salutejs/plasma-asdk@0.133.1-canary.1380.10485553077.0
yarn add @salutejs/plasma-b2c@1.375.1-canary.1380.10485553077.0
yarn add @salutejs/plasma-new-hope@0.128.2-canary.1380.10485553077.0
yarn add @salutejs/plasma-web@1.376.1-canary.1380.10485553077.0
yarn add @salutejs/sdds-cs@0.105.1-canary.1380.10485553077.0
yarn add @salutejs/sdds-dfa@0.103.1-canary.1380.10485553077.0
yarn add @salutejs/sdds-serv@0.104.1-canary.1380.10485553077.0

Copy link
Contributor

Theme Builder app deployed!

https://plasma.sberdevices.ru/pr/plasma-theme-builder-pr-1380/

Copy link
Contributor

⚡ Component performance testing

Result: 🟢 OK

@Yakutoc Yakutoc added plasma-components and removed bugs Something isn't working labels Aug 21, 2024
@vadim-kudr vadim-kudr changed the title fix: Fix Modal overflow-y side effect fix: Fix Modal Overlay & Popup registration logic Aug 21, 2024
Copy link
Contributor

@denivladislav denivladislav Aug 21, 2024

Choose a reason for hiding this comment

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

if (index === -1) { return prevItems; }

Тут тоже нужно [...prevItems] ?

Copy link
Contributor Author

@vadim-kudr vadim-kudr Aug 21, 2024

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.

Получается в одном сеттере мы делаем и возврат без обновления и возврат с обновлением. Мне кажется, это неочевидным моментом в коде, который лучше обойти. Что думаешь?

Мб вернуться к варианту, когда мы сначала просто подбираем items из useState, ищем индекс, а дальше идет guard expression?

const index = items.findIndex((item: PopupInfo) => id === item.id);
if (index === -1) {
     return;
} 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

звучит хорошо. в текущей реализации еще useCallback не хватает. вот нужны ли они, изменение items все равно контекст обновит, нужно подумать

const register = useCallback(() => setState(() => ...), []);
const unregister = useCallback(() => setState(() => ...), []);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

что-то там с замыканиями было на items, поэтому через setItems сделано, ща попробую проще сделать

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

в items старые значения, как-будто замыкание на что-то другое идет, поэтому через setItems(() => ...)

@Yakutoc Yakutoc changed the title fix: Fix Modal Overlay & Popup registration logic plasma-*: Fix Modal Overlay & Popup registration logic Aug 21, 2024
@@ -65,7 +65,7 @@ export const modalRoot = (Root: RootProps<HTMLDivElement, ModalProps>) =>
popupInfo,
});

const transparent = useMemo(() => getIdFirstModal(popupController.items) !== innerId, [
const transparent = useMemo(() => getIdLastModal(popupController.items) !== innerId, [
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 Author

Choose a reason for hiding this comment

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

можно убрать, не стал старый код трогать

@vadim-kudr vadim-kudr added this pull request to the merge queue Aug 21, 2024
Merged via the queue into dev with commit 699a02f Aug 21, 2024
30 checks passed
@vadim-kudr vadim-kudr deleted the PLASMA-3252-fix branch August 21, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants