Skip to content

Conversation

Hugo-Prossaird
Copy link
Contributor

@Hugo-Prossaird Hugo-Prossaird commented Mar 21, 2025

Q A
Bug fix? (use the a.b branch) ✔️
New feature/enhancement? (use the a.x branch) ✔️
Deprecations?
BC breaks? (use the c.x branch)
Automated tests included? ✔️
Related user documentation PR URL mautic/user-documentation#...
Related developer documentation PR URL mautic/developer-documentation-new#...
Issue(s) addressed Fixes #...

Description

Clone lead fields redirect to Edit view, instead of Clone. This PR updates it to use the same logic as Segment.


📋 Steps to test this PR:

  • Go to Custom fields and try to clone an existing lead custom field

Capture d’écran 2025-03-21 à 11 23 28

Before: Redirected to /edit route

Capture d’écran 2025-03-21 à 11 27 46

After: Redirect to /clone

Capture d’écran 2025-03-21 à 11 23 46

Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.72%. Comparing base (82e71b6) to head (3daba7b).
Report is 31 commits behind head on 5.2.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                5.2   #14780      +/-   ##
============================================
+ Coverage     63.70%   63.72%   +0.01%     
- Complexity    34683    34684       +1     
============================================
  Files          2274     2274              
  Lines        103768   103771       +3     
============================================
+ Hits          66106    66126      +20     
+ Misses        37662    37645      -17     
Files with missing lines Coverage Δ
.../bundles/LeadBundle/Controller/FieldController.php 41.77% <100.00%> (+5.65%) ⬆️
app/bundles/LeadBundle/Entity/LeadField.php 97.85% <100.00%> (+1.36%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Hugo-Prossaird Hugo-Prossaird marked this pull request as ready for review March 21, 2025 11:12
@matbcvo
Copy link
Contributor

matbcvo commented Mar 21, 2025

Cloning doesn't work as expected. I would expect the custom field to be cloned after clicking the Save button once. I currently need to click the Save button three times before the clone is actually created.

Aslo the max character limit field does not inherit the value from the original item - it should be copied automatically during the cloning.

An error also appears after the first attempt to save.

Screen.Recording.2025-03-21.140108.mp4

@matbcvo matbcvo added pending-feedback PR's and issues that are awaiting feedback from the author bug Issues or PR's relating to bugs labels Mar 21, 2025
@Hugo-Prossaird
Copy link
Contributor Author

Cloning doesn't work as expected. I would expect the custom field to be cloned after clicking the Save button once. I currently need to click the Save button three times before the clone is actually created.

Aslo the max character limit field does not inherit the value from the original item - it should be copied automatically during the cloning.

An error also appears after the first attempt to save.

Screen.Recording.2025-03-21.140108.mp4

Fixed !
If we tried to clone a fixed field, it remained 'unwritable,' and some properties were not persisted in the clone. Now, it should work like a normal field clone.

Capture d’écran 2025-03-28 à 11 36 01

@matbcvo matbcvo added this to the 5.2.5 milestone Mar 28, 2025
@kuzmany kuzmany added ready-to-test PR's that are ready to test and removed pending-feedback PR's and issues that are awaiting feedback from the author labels Mar 28, 2025
@escopecz
Copy link
Member

I actually like how it is done in segments. If you clone a segment with ID 9 then it will go to route /s/segments/clone/9. It's not edit nor new. Its very clear what's happening and you don't have to somehow store the ID of the original segment in a HTML hidden input or session. That's how it should have been done for all entities. When we are fixing it here, can it be done this way too?

Copy link

@imaabasiee imaabasiee left a comment

Choose a reason for hiding this comment

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

Cloned custom fields now redirects to /new and clones successfully
https://www.loom.com/share/0a2f1247b5c749c9af226ccc22d21ad2?sid=21d4ce6e-7b0a-4c84-a525-858de322b733

@Hugo-Prossaird
Copy link
Contributor Author

Hugo-Prossaird commented Apr 4, 2025

I actually like how it is done in segments. If you clone a segment with ID 9 then it will go to route /s/segments/clone/9. It's not edit nor new. Its very clear what's happening and you don't have to somehow store the ID of the original segment in a HTML hidden input or session. That's how it should have been done for all entities. When we are fixing it here, can it be done this way too?

Now it's using the same logic as segment cloning:
Capture d’écran 2025-04-04 à 10 08 10

Redirects to:

Capture d’écran 2025-04-04 à 10 08 16

I'll take a look at the tests later :)

@matbcvo
Copy link
Contributor

matbcvo commented Apr 23, 2025

Hey @Hugo-Prossaird, just a heads up, the 5.2.5 release is happening on April 28th. It’d be great if you could resolve those failing tests so we can get it merged in time.

@oltmanns-leuchtfeuer oltmanns-leuchtfeuer moved this from ⏳︎ Needs 1 more test to 🧑🏻‍💻 Needs a code review in Open Source Fridays Apr 25, 2025
@matbcvo matbcvo requested a review from escopecz April 26, 2025 14:24
Copy link
Member

@RCheesley RCheesley left a comment

Choose a reason for hiding this comment

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

Thanks @Hugo-Prossaird great catch, and good to be aligning the behaviour with the way segment cloning works in the process, too.

@matbcvo matbcvo modified the milestones: 5.2.5, 5.2.6 Apr 28, 2025
@github-project-automation github-project-automation bot moved this from 🧑🏻‍💻 Needs a code review to 🚨 Developer revision needed in Open Source Fridays Apr 28, 2025
@escopecz escopecz added the pending-feedback PR's and issues that are awaiting feedback from the author label Apr 30, 2025
@Hugo-Prossaird Hugo-Prossaird requested a review from escopecz May 16, 2025 06:53
@kuzmany kuzmany removed the pending-feedback PR's and issues that are awaiting feedback from the author label May 23, 2025
@nick-vanpraet nick-vanpraet modified the milestones: 5.2.6, 5.2.7 May 26, 2025
@npracht
Copy link
Member

npracht commented Jun 13, 2025

@escopecz one last checkout following your review and related changes and then we can merge ! Thanks :)

@npracht npracht added custom-fields Anything related to custom fields T1 Low difficulty to fix (issue) or test (PR) and removed code-review-needed PR's that require a code review before merging labels Jun 13, 2025
@escopecz escopecz added the code-review-passed PRs which have passed code review label Jun 16, 2025
Copy link
Member

@escopecz escopecz left a comment

Choose a reason for hiding this comment

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

The code changes look great. Thanks! 👍

@escopecz escopecz added the ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged label Jun 16, 2025
@escopecz escopecz merged commit d9a8699 into mautic:5.2 Jun 16, 2025
17 checks passed
@github-project-automation github-project-automation bot moved this from 🚨 Developer revision needed to 🥳 Done in Open Source Fridays Jun 16, 2025
@kuzmany kuzmany changed the title Fix: Clone custom field logic Fix custom field duplication when cloning contacts Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs code-review-passed PRs which have passed code review custom-fields Anything related to custom fields ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged T1 Low difficulty to fix (issue) or test (PR) user-testing-passed PRs which have been successfully tested by the required number of people.
Projects
Status: 🥳 Done
Development

Successfully merging this pull request may close these issues.

9 participants