This is the expected behavior for Flow screen components.
Text fields in flow are optimized for a case where the value may need to be initialized to a default value, but once the user enters something else, the text field should not be reset.
For lightning component based screen flow inputs (including the "standard" inputs that are built/delivered by Salesforce out-of-the-box as lightning components), the behavior will be the same except for the case where an attribute has either its input mapped, or its output mapped, but not both or neither. Confusing? Yeah. Probably. But that's how it works.
For your custom LWCs, you can work around this by having separate "inputValue" and "outputValue" attributes, then only mapping an input for the "inputValue" attribute and manually assigning the output to the "outputValue". This will force the component to recalculate every time the screen is visited.
Alex Edelstein goes over this in painstaking detail on his blog here:
Optimizing Lightning Component Inputs and Outputs in Flow Screens
Also, it is worth noting that in my Spring 21 preview org, I see a new Advanced option that would allow you to set this behavior explicitly rather than implement the workaround I described. Safe harbor probably applies, but it looks promising:
Immediately after posting my question, I stumbled upon the solution. Or a solution. I simply deleted the offending properties from the .js-meta.xml
file, and I was able to deploy my change. Then I added them back (literally undid my edit) and deployed again, and no issue.
Best Answer
you can do this by using this function explained here
So for example, let's say I have a component like this,
Javascript
Html
XML
When I try to click next, without inputing the number, so number will be null, hence it won't let me go to the next screen and will show the error message from the validate function's else statement.
Hope it helps :)