Skip to content

MWPW-186621: Fix mnemonic icon/field inheritance#547

Open
yesil wants to merge 27 commits intomainfrom
MWPW-186621
Open

MWPW-186621: Fix mnemonic icon/field inheritance#547
yesil wants to merge 27 commits intomainfrom
MWPW-186621

Conversation

@yesil
Copy link
Contributor

@yesil yesil commented Jan 26, 2026

Resolves

image

QA Checklist: https://wiki.corp.adobe.com/display/adobedotcom/M@S+Engineering+QA+Use+Cases

Please do the steps below before submitting your PR for a code review or QA

  • C1. Cover code with Unit Tests
  • C2. Add a Nala test (double check with #fishbags if nala test is needed)
  • C3. Verify all Checks are green (unit tests, nala tests)
  • C4. PR description contains working Test Page link where the feature can be tested
  • C5: you are ready to do a demo from Test Page in PR (bonus: write a working demo script that you'll use on Thursday, you can eventually put in your PR)
  • C.6 read your Jira one more time to validate that you've addressed all AC's and nothing is missing

🧪 Nala E2E Tests

Nala tests run automatically when you open this PR.

To run Nala tests again:

  1. Add the run nala label to this PR (in the right sidebar)
  2. Tests will run automatically on the current commit
  3. Any future commits will also trigger tests as long as the label remains

To stop automatic Nala tests:

  • Remove the run nala label

Note: Tests only run on commits if the run nala label is present. Add the label whenever you need tests to run on new changes.

Test URLs:

@aem-code-sync
Copy link

aem-code-sync bot commented Jan 26, 2026

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

@yesil yesil changed the title Mwpw 186621 MWPW-186621: Fix mnemonic icon/field inheritance Jan 26, 2026
…nd preview stores to share the same fields array, leading to unintended mutations when restoring mnemonic fields to parent values

Deep clone fields array in replaceFrom to ensure source and preview fragment stores remain independent
Simplify resetMnemonicsToParent now that the underlying bug is fixed
Add unit test for merch-card-editor mnemonic inheritance flow (remove → override → restore)
@yesil
Copy link
Contributor Author

yesil commented Jan 28, 2026

cursor review

@cursor
Copy link

cursor bot commented Jan 28, 2026

Skipping Bugbot: Bugbot is disabled for this repository

@yesil
Copy link
Contributor Author

yesil commented Feb 2, 2026

cursor review

@cursor
Copy link

cursor bot commented Feb 2, 2026

Skipping Bugbot: Bugbot is disabled for this repository

@yesil
Copy link
Contributor Author

yesil commented Feb 2, 2026

cursor review

@cursor
Copy link

cursor bot commented Feb 2, 2026

Skipping Bugbot: Bugbot is disabled for this repository

Copy link
Member

@Axelcureno Axelcureno left a comment

Choose a reason for hiding this comment

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

Found 2 significant issues with this changes and proposed fixes for both.

Screenshot 2026-02-02 at 11 01 54 AM Screenshot 2026-02-02 at 11 02 10 AM >

* @param {Fragment} parentFragment
* @returns {object}
*/
function createPreviewDataWithParent(sourceFragment, parentFragment) {
Copy link
Member

Choose a reason for hiding this comment

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

Code duplication of #createPreviewData()

Copy link
Member

Choose a reason for hiding this comment

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

You will need to add the same parent-merging logic in discardChanges() here. Without this, saving a variation causes inherited content to disappear from the preview and breaks the experience.

Suggested change
// For variations, restore preview with parent-merged values (same as discardChanges)
if (this.parentFragment) {
const previewData = this.#createPreviewData(this.value, this.parentFragment);
this.previewStore.refreshFrom(previewData);
} else {
this.previewStore.refreshFrom(structuredClone(value));
}

return ownField.values;
const ownValues = ownField?.values || [];

// [] (empty array) = inherit from parent if variation
Copy link
Member

Choose a reason for hiding this comment

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

Although this solves a real problem, I'm really not a fan of this brittle distinction of [] vs ['']. Why not use an explicit inherited flag instead?
After all the goal is to make the code simpler and more obvious.

Copy link
Contributor Author

@yesil yesil Feb 4, 2026

Choose a reason for hiding this comment

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

brittle distinction of [] vs [''].

This has been properly covered with tests now, I don't consider it brittle.
I don't have strong preference though, let's run by @npeltier, was this already decided as inherited ?

<mas-multifield
id="mnemonics"
button-label="Add visual"
data-field-state="${this.getFieldState('mnemonicIcon')}"
Copy link
Member

@Axelcureno Axelcureno Feb 2, 2026

Choose a reason for hiding this comment

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

This causes all variation mnemonics to show as "overridden" when the user adds a mnemonic.
field-state.js must return 'same-as-parent' instead of '' (empty string) to prevent multifield fallback to this container state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't adding a mnemonic considered as override?

@yesil
Copy link
Contributor Author

yesil commented Feb 3, 2026

cursor review

@cursor
Copy link

cursor bot commented Feb 3, 2026

Skipping Bugbot: Bugbot is disabled for this repository

@yesil
Copy link
Contributor Author

yesil commented Feb 3, 2026

@Axelcureno the PR is not in review yet, I'm still dealing with some of the issues you mentioned. I'll move the JIRA to review once ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants