#Input widget is staying enabled, even when disabled javascript code is true.

1 messages · Page 1 of 1 (latest)

glad pine
#

I'm having an issue with an input widget staying enabled, even when it's disabled javascript code evaluates to true.

When the modal first loads, the disabled javascript code evaluates to true, and the input widget is disabled. If I push a button it will inputWidget.setDisabled(false) which enables the input widget. If I reset the input widget, it will stay enabled, even through the disabled javascript code still resolves to false. How can I get the input widget to disable based on its disabled javascript code?

Input widget Disabled code: {{Table1Copy.selectedRowIndex < 0}} Table1Copy.selectedRowIndex equals -1
Button1 onClick code: {{inputWidget.setDisabled(false)}}
Button2 onClick code:{{resetWidget("inputWidget")}}
After pusing Button2, the input widget remains enabled, even though the Disabled code resolves to true.

worldly ravineBOT
#

Hello! I'm AppyBot, here to assist you with your Appsmith concerns. For the
issue you are experiencing with the input widget, it seems like the
resetWidget action might not be resetting the custom set properties on the
widget, such as the disabled state changed by setDisabled. You can try to
include a call to reset the disabled state of the widget manually within your
Button2 onClick code. Here is a modified version of Button2's onClick
script: {{ inputWidget.setDisabled(true); resetWidget("inputWidget"); }}
This ensures that after the input widget is reset, it will also respect the
disabled Javascript condition and become disabled if
Table1Copy.selectedRowIndex is less than 0. Give this a try and see if it
resolves the issue. If you still encounter problems, please let me know! If you
don't find my response helpful, you can request to speak to a human agent

glad pine
#

That wouldn't work because in my app, Button2 is supposed to reset the input widget to empty, and disabled. If I just disable it, the text is still there.

worldly ravineBOT
#

Apologies for the confusion earlier. It seems you want to reset the input widget
to be both empty and disabled when Button2 is clicked, and for it to respect the
disabled JavaScript condition based on Table1Copy.selectedRowIndex. To achieve
this, you might want to use the storeValue function to store the disabled
state in the Appsmith store and use this value to set the disabled state of the
input widget. For example: - Use storeValue in Button1 onClick to save the
disabled state as false when the input is enabled. {{ storeValue('isInputDisabled', false); inputWidget.setDisabled(false); }} -
Modify the input widget's Disabled code to refer to this stored value as well:
{{ appsmith.store.isInputDisabled || Table1Copy.selectedRowIndex < 0 }}

  • Then, in Button2's onClick, you would reset the input widget and store the
    disabled state as true to ensure it's disabled. {{ inputWidget.setText(''); storeValue('isInputDisabled', true); inputWidget.setDisabled(true); }} Now,
    your input widget will be empty and disabled when Button2 is clicked, and it
    should also become disabled based on the condition from
    Table1Copy.selectedRowIndex when the modal loads or when the selection
    changes. Please try this approach and see if it resolves your issue. If you
    don't find my response helpful, you can request to speak to a human agent
glad pine
#

This seems like a big work around. . . shouldn't the resetWidget function reevaluate the disabled code and disable accordingly? Is the Disabled code supposed to be ignored on a widget reset?

worldly ravineBOT
#

I understand your concerns. Ideally, the resetWidget function should
re-evaluate the properties of the widget, including the Disabled JavaScript
condition. If it's not behaving as expected, it might be an issue with the
function or the platform. The Disabled JavaScript code should not be ignored
during a widget reset; the widget should indeed return to its initial state as
determined by its binding expressions. If the behavior you are encountering
differs from this, it could be indicative of a bug or unintended behavior in
Appsmith. In such a case, I would recommend reporting this to the Appsmith team
for further investigation. In the meantime, the previous workaround I provided
is aimed at mitigating the issue temporarily. However, if you believe the
platform should handle this scenario inherently, it would be best to reach out
to the Appsmith support or file an issue on their GitHub repository for a more
permanent solution. They might need more specific details about your Appsmith
version and the steps that lead to the observed behavior for a thorough
investigation. If you don't find my response helpful, you can request to speak
to a human agent

glad pine
#

The work around I have implemented is using inputWidget.setDisabled(true) followed by resetWidget("inputWidget"). This does accomplish what I'm trying to do with the button.

worldly ravineBOT
#

I'm glad to hear you've found a workaround that accomplishes your goal by
combining inputWidget.setDisabled(true) with resetWidget("inputWidget").
This effectively resets the widget and then manually sets it to be disabled.
Just to clarify, when you reset a widget using resetWidget, it should ideally
evaluate all its properties based on their bindings, including the disabled
state. If the Disabled property is still not updating as it should after a
reset, it might be worth bringing this behavior to the Appsmith team's attention
for potential improvements or bug fixes. However, if the workaround you've
implemented is serving your purpose without causing any additional issues, you
could continue using it as a reliable solution until any platform updates
address this behavior. If you encounter any further issues or have more
questions, feel free to reach out. If you don't find my response helpful, you
can request to speak to a human agent