You need to sign in to do that
Don't have an account?
Kevin Zhou 13
Input sometimes disappears
I'm using the built-in input validation feature. When an invalid input is entered and the user clicks outside the input box, sometimes that input disappears; the associated error message does not get displayed. I'd prefer the invalid input to remain in the input box. What might cause the input to sometimes disappear?
Can you share more details about the built-in input validation feature? Can you share the click path of steps to repro?
<lightning-input type="date" data-my-id="myDate"
class="inttDate inputDateField slds-size_8-of-12 slds-m-top_xxx-small" name="myDate"
min="2022-01-01" max="2022-12-31" message-when-range-overflow="Invalid input: overflow"
message-when-range-underflow="Invalid input: underflow" variant="label-hidden"
value={myDate} onchange={myDateChange}
message-when-bad-input="Invalid input: general">
</lightning-input>
Here's my js file:
myDateChange(event) {
let inputDate = this.template.querySelector("lightning-input[data-my-id= myDate]");
if (inputDate.value) {
this.myDate = event.target.value;
}
else {
this.prodRequestCompletionDate = getConstants().EMPTY; // this sometimes causes input to disappear
}
inputDate.reportValidity();
}
const getConstants = () => {
return {
EMPTY : '',
FILLED : 'Filled'
}
}
Hi Kevin Zhou 13,
Looks like you are trying to modify the field value when there is a value in it.
if (inputDate.value) {
this.myDate = event.target.value;
}
I suggest to just to the validation and dont modify the field value. Please refer to the code below:
Thank you,
Vinay.