Scenario
A flow screen with a normal text field (call it field A) and a picklist LWC that takes some default value and stores an output variable based on user interaction.
When field A has an input validation, the screen does not progress to the "next" part of the flow and rather stays on the same screen. In this specific scenario, the LWC loses any user entered information and reverts to initial state.
Details
LWC is just a combobox.
<lightning-combobox
name={fieldLabel}
label={fieldLabel}
value={selectedValue}
options={options}
onchange={handleChange}>
</lightning-combobox>
I'm passing a default value (selectedValue
) as an input and I'm storing the output (if the user changes the value) in a text variable. The input/output variables for the LWC are the same to support retaining the selection if users use previous/next. But, by not progressing - it seems the output variable from the LWC is never saved.
This article goes over various situations, but it focuses on the "next" and "previous" button whereas my scenario is due to how the input validation works in flow screens (preventing you from progressing, but seemingly refreshing).
The out of the box fields obviously retain their values - just not the LWC. Looking at the console logs, the LWC essentially is re-initialized when the input validation on the screen fires and the "default values" passed in the flow are using the non-user changed values (what they were before the screen appeared).
Is there any way to retain user-entered information in a LWC if the flow screen flags an input validation on a separate field and doesn't progress?