Skip to content

Fix: adjust attribute name "disable" to match what is defined in multi-select.js#3014

Merged
chrisknoll merged 2 commits intoOHDSI:masterfrom
uc-cdis:fix/multi_select
Apr 15, 2025
Merged

Fix: adjust attribute name "disable" to match what is defined in multi-select.js#3014
chrisknoll merged 2 commits intoOHDSI:masterfrom
uc-cdis:fix/multi_select

Conversation

@pieterlukasse
Copy link
Contributor

@pieterlukasse pieterlukasse commented Apr 11, 2025

See also https://github.com/OHDSI/Atlas/pull/2975/files#r2040084688

Fixes error below:

knockout-latest.js:16 Uncaught ReferenceError: Unable to process binding "if: function(){return multiple == true }"
Message: Unable to process binding "attr: function(){return disabled }"
Message: disabled is not defined

@pieterlukasse
Copy link
Contributor Author

CC @anthonysena

@anthonysena anthonysena self-requested a review April 13, 2025 14:48
Copy link
Collaborator

@anthonysena anthonysena left a comment

Choose a reason for hiding this comment

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

I think I introduced this bug based on the work you noted here: https://github.com/OHDSI/Atlas/pull/2975/files#r2040084688. Shouldn't we change the multi-select component to use disabled since that is the desired HTML attribute?

@chrisknoll
Copy link
Collaborator

A few notes on this:

  1. The attr data-binding docs: this is a cool binding allowing you to set multiple HTML dom attributes in 1 expression based on the values from the view model. Works with things like title, href, etc where it's an attribute-value set up.
  2. the html disabled attribute dom docs: marks an element disabled. Note it doesn't have a name-value pair sort of assignment. Just the presence of disabled disables the dom element.
  3. the enabled / disabled data-binding: This seems to bet he data-binding that is associated with disabling DOM elements.

Given the above, does the attr:disabled binding work the way we think? I imagine it would based on that I think we've seen correct disabled behavior here. In the context of this PR, we need to call the attribute 'disabled' (the view model variable name doesn't matter). But would it be more appropriate to associate the disabled data binding to this function instead of the proper naming of the HTML dom attribute?

@pieterlukasse
Copy link
Contributor Author

pieterlukasse commented Apr 14, 2025

thanks for the review! I changed it based on @chrisknoll 's shared link https://knockoutjs.com/documentation/enable-binding.html. Maybe you can try it to see if it works in the scenarios you intended it for? The solution is maybe still not correct if the intention is to have the enabled/disabled status change dynamically in a reactive way in the UI.

Copy link
Collaborator

@anthonysena anthonysena left a comment

Choose a reason for hiding this comment

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

Thanks for sharing those resources @chrisknoll and to @pieterlukasse for making the updates. The intent with the disable property of the component is to use the disabled HTML attribute so these changes look good from my side.

@chrisknoll
Copy link
Collaborator

Thanks @pieterlukasse .

In the future, can you please not force push branches that have been made into a PR? I think this causes issues where people have pulled down the branch locally and then try to pull again but their parent commit looks different than the forced commit that was pushed to the server, and it leads to strange messages (like you have un-pushed local changes when you try to pull a second time).

@chrisknoll
Copy link
Collaborator

chrisknoll commented Apr 14, 2025

To answer your question about if it works dynamicaly:

The view-model field that the HTML template is binding to is called 'disable', defined here:

self.disable = (params.disable || false);

It will respond dynamically depending on what is in the params.disable payload (ie: what the component is being initialized with):

  1. An observable: if params.disable is an observable, then self.disable will reference it as the observable that was apassed in, and the disable data-bind will redraw whenever the observable state changes automatically.
  2. A plain boolean object: If you data-bind (via the disable: binding for example) to a non-observable value, the data-bind will not respond to anything and so whatever the initial state of the param is will be the final state of the DOM element.
  3. nothing at all: If it is nothing then the || false clause takes effect, and the binding will bind to a non-observable value of false and follow item 2 above.

@chrisknoll chrisknoll merged commit a28e3cc into OHDSI:master Apr 15, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants