Open
Description
switcherconfig_test_module.zip
Preconditions and environment
- Magento open source version 2.4.4 and 2.4.6
- nginx
- elasticsearch
- MariaDB 10.4.25
- php 8.1
- A customer record with an address
- Install attached module to reproduce issue
Steps to reproduce
- Install attached module
- Login to admin backend
- Edit a customer
- Edit the customer's address
- Click field1 once or twice to see the hide/show effect (rules)
- Close the modal
- Edit the address again
- Click field1 once or twice - hide/show rules no longer work (nor on page load either)
See attached recording.
Veronica.Costello._.Customers._.Customers._.Magento.Admin.webm
Expected result
The switcherConfig should work every time the modal is opened to add or edit an address.
Actual result
switcherConfig stop working after the modal is first closed. Subsequent openings no longer execute the switcherConfig rules.
There are no JS console or system/exception log errors that I can see.
Additional information
It has happens in the customer address form for both add or edit addresses.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Activity
m2-assistant commentedon Jan 18, 2025
Hi @xtremevision. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.
@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
[-]switcherConfig stop working in admin customer address edit modal[/-][+]switcherConfig stops working in admin customer address edit modal[/+]xtremevision commentedon Jan 19, 2025
From what I can tell static/version1737174762/adminhtml/Magento/backend/en_US/Magento_Ui/js/form/switcher.js function
does not execute anymore. Not sure yet why but the onChange event is not firing anymore. Could there be a ko binding problem?
xtremevision commentedon Jan 20, 2025
I would be more than happy to reproduce the issue on a vanilla Magento but I don't know how to request the instance with my module installed. Is it possible?
smartexcan commentedon Jan 20, 2025
I'm pretty sure I know why this is happening.
The switcher object for the field is not destroyed/cleaned up when the form is destroyed and re-rendered.
You can test this in your browser (with the test module installed):
require('uiRegistry').remove('customer_address_form.customer_address_form.general.field1_switcher')
You can use this mixin as a temporary fix:
(file paths are listed in comments for the files, update the vendor/module parts as needed)
https://gist.github.com/smartexcan/c4f3ee62e14b251a9c09cacf4943bc3b
I made a pull request for this almost a year ago that hasn't been looked at yet lol
#37512
xtremevision commentedon Jan 20, 2025
Perhaps I am missing something but it's not working, see console in screenshot.
smartexcan commentedon Jan 20, 2025
Ah right, it doesn't have a destroy method (which is the problem).
try the following:
require('uiRegistry').remove('customer_address_form.customer_address_form.general.field1_switcher')
and replace
general
andfield1
with whatever your fieldset and field names arextremevision commentedon Jan 20, 2025
This worked
require('uiRegistry').remove('customer_address_form.customer_address_form.general.field1_switcher')
Well done!
xtremevision commentedon Jan 20, 2025
I'll use a composer patch for now to get this working as I have custom module pending that can't be finished due to this bug. Thanks @smartexcan !
xtremevision commentedon Jan 22, 2025
@smartexcan I've just tested it with composer patches, works like a charm! Well done my friend. :)
For anyone wanting the patches until the PR is merged:
and
33 remaining items