-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change logic of the useVIewCartPixel hook (#335)
#### What problem is this solving? The app has problems with pushing view_cart pixel event when variant="drawer". This problem happens because of the wrong logic of handling open/close state of the Drawer component. It switches isOpen from true to false and back when user presses on the Cart Button in the store front header: 1. User presses on the Cart button --> isOpen changes to true --> view_cart event is pushed; 2. User presses on the close Drawer button --> nothing changed; 3. User presses on the Cart button --> isOpen changed to false --> view_cart event is not pushed because isOpen state == false. To solve this wrong behavior I added onVisibilityChanged callback function as a property argument to the Drawer component in the drawer app and made these changes in the minicart app to handle open/close events properly. #### How to test it? In the browser inspector console tab type dataLayer to see events that have been pushed. It should add view_cart event on every Drawer opening and when user adds a new product to the cart (at the moment when Drawer is opening) https://devalex--dunnesstorespreprod.myvtex.com/ #### Screenshots or example usage: https://github.com/user-attachments/assets/aff7f680-d649-452a-8837-30242f287454 https://github.com/user-attachments/assets/adeb1c36-71e8-45ca-8778-e6e9e3a419d6 ![Снимок экрана 2024-08-02 в 15 13 17](https://github.com/user-attachments/assets/c702ae07-fa85-41ee-9db5-9be349b9cb26) #### Related PR vtex-apps/drawer#75
- Loading branch information
1 parent
e407f3b
commit bcbe843
Showing
6 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters