Skip to content

Commit

Permalink
trigger chained actions on shadows only for click/focus
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Sep 26, 2023
1 parent fb5b2e8 commit 9b41c73
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
30 changes: 14 additions & 16 deletions packages/doenetml/src/Core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -10697,22 +10697,20 @@ export default class Core {
actionsToChain.push(...this.actionsChangedToActions[id]);
}

if (comp?.shadows) {
if (
["focus", "click"].includes(triggeringAction) &&
cName.substring(0, 3) !== "/__"
) {
// for focus and click, we propagate to shadows only if
// the copied component doesn't have a name.
// In this way, if we include $P in a graph,
// then triggerWhenObjectsClicked="P" and triggerWhenObjectsFocused="P"
// will be triggered by that copy,
// but these actions will not be triggered if that copy has a name.
// TODO: if <point copySource="P" /> no longer has a name like "_point1",
// should triggerWhenObjectsClicked="P" be triggered from that point?
// Currently, it is not triggered.
break;
}
if (
comp?.shadows &&
["focus", "click"].includes(triggeringAction) &&
cName.substring(0, 3) === "/__"
) {
// for focus and click, we propagate to shadows if
// the copied component doesn't have a name.
// In this way, if we include $P in a graph,
// then triggerWhenObjectsClicked="P" and triggerWhenObjectsFocused="P"
// will be triggered by that copy,
// but these actions will not be triggered if that copy has a name.
// TODO: if <point copySource="P" /> no longer has a name like "_point1",
// should triggerWhenObjectsClicked="P" be triggered from that point?
// Currently, it is not triggered.
cName = comp.shadows.componentName;
} else {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ describe("UpdateValue Tag Tests", function () {
});
});

it("chained updates, copies copy triggers", () => {
it("chained updates, copies don't copy triggers", () => {
cy.window().then(async (win) => {
win.postMessage(
{
Expand Down Expand Up @@ -1240,17 +1240,17 @@ describe("UpdateValue Tag Tests", function () {

cy.get(cesc2("#/uv2")).click();
cy.get(cesc2("#/n")).should("have.text", "3");
cy.get(cesc2("#/m1")).should("have.text", "3");
cy.get(cesc2("#/m1")).should("have.text", "2");
cy.get(cesc2("#/m2")).should("have.text", "2");

cy.get(cesc2("#/uv3")).click();
cy.get(cesc2("#/n")).should("have.text", "4");
cy.get(cesc2("#/m1")).should("have.text", "4");
cy.get(cesc2("#/m1")).should("have.text", "2");
cy.get(cesc2("#/m2")).should("have.text", "2");

cy.get(cesc2("#/pmacro") + " button").click();
cy.get(cesc2("#/n")).should("have.text", "5");
cy.get(cesc2("#/m1")).should("have.text", "5");
cy.get(cesc2("#/m1")).should("have.text", "2");
cy.get(cesc2("#/m2")).should("have.text", "2");
});

Expand Down

0 comments on commit 9b41c73

Please sign in to comment.