Changing the membership type causes multiple copies of related membership text on edit membership page
Overview
If a membership cascades to related contacts some text is displayed next to the 'Max related' field which shows the number of eligible contacts that could inherit the membership. This text is added automatically when the membership type is selected. The issue is that the text is added every time the membership type is changed. So if you change the membership type backwards and forwards a few times you will get several copies of this text.
This is a very minor issue that probably doesn't cause much real world pain. In fact I may have been the only person to have ever noticed it... However it's not working right and it would be good to fix it.
Reproduction steps
- Visit a demo site or use dmaster
- View a contact
- Visit the membership tab
- Create or edit a membership
- Select the 'General' membership type
- Select the 'Lifetime' membership type
- Select the 'General' membership type
- Select the 'Lifetime' membership type
- Repeat a few times - you get the idea
Current behaviour
If you look at the text next to the 'Max Related' field you will see multiple copies of 'One contact is currently eligible to inherit this relationship.'
Expected behaviour
Only one copy of this text is displayed.
Environment information
- Browser: N/A
- CiviCRM: Master
- PHP: N/A_
- CMS: N/A
- Database: N/A
- Web Server: N/A
Comments
Here is the line in the code that is responsible for this behaviour:
cj('#max_related').siblings('.description').append(' ' + relatable);
https://github.com/wmortada/civicrm-core/blob/master/templates/CRM/Member/Form/Membership.tpl#L667