FLUID-5885: Component context for {that} in indirect model listener is incorrect

Metadata

Source
FLUID-5885
Type
Bug
Priority
Major
Status
Closed
Resolution
Cannot Reproduce
Assignee
Antranig Basman
Reporter
Antranig Basman
Created
2016-04-12T16:37:39.051-0400
Updated
2024-07-22T09:27:11.013-0400
Versions
N/A
Fixed Versions
N/A
Component
  1. Framework

Description

FLUID-5848 implemented support for indirect model references (that is, those where the path segment "model" did not appear in the head position after the component context reference). Unfortunately this exposed an assumption/bug in the dispatch pathway - that the component where the listener is to be registered is the same as that where the reference is written. The following configuration:

fluid.defaults("onward.adaptation", {
        gradeNames: "fluid.modelComponent",
        components: {
            button: {
                type: "fluid.button",
            }
        },
        modelListeners: {
            "{that}.button.model.pressed": {
                namespace: "toggleAdaptation",
                funcName: "onward.toggleAdaptationContext",
                args: ["{change}.value", "{that}.options.contextGrade"]
            }
        }
    });

surprises the user because the value of {that} when resolving {that}.options.contextGrade refers to the button (at path {that}.button) rather than the context where it is written, being onward.adaptation

Comments