I'm facing alignment issues with search icon and error message in salesforce LWC - html

I want the search icon to stay in place when getting the error message. However, I get an alignment issue and it moves down with the error message.
<lightning-layout-item padding="vertical-small" size="3" class="slds-var-p-left_x-small ">
<div class="slds-var-p-bottom_xx-small">
<Label id="ResidencePINCodeLabel"
class="greyh6regularleft">Residence PIN
Code*</Label>
</div>
<div class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right"
onkeyup={handlePincodeSearch}>
<lightning-icon size="x-small" icon-name="utility:search"
class="slds-icon slds-input__icon slds-var-m-bottom_large">
</lightning-icon>
<template if:false={selectedPinCodeValue}>
<lightning-input pattern="[0-9]{6}" autocomplete="off" label=""
required="true" variant="label-hidden" type="tel"
aria-labelledby="ResidencePINCodeLabel"
placeholder="PIN Code" name="PincodeLWC__c" message-when-pattern-mismatch="Not Valid PIN Code"
class="zip-handler input-background">
</lightning-input>
</template>
<template if:true={selectedPinCodeValue}>
<lightning-input pattern="[0-9]{6}" autocomplete="off" label="" type="tel"
required="true" variant="label-hidden"
value={selectedPinCodeName} message-when-pattern-mismatch="Not Valid PIN Code"
aria-labelledby="ResidencePINCodeLabel"
placeholder="PIN Code" name="PincodeLWC__c"
class="zip-handler input-background">
</lightning-input>
</template>
</div>
Image of the error
Please help me! Thank you!

Related

How does this HTML block the auto insertion of my email address from chrome?

At first I thought it was some jerk move to make me type my username for added "security" on top of 2FA so I decided to fix it with tampermonkey and remove the autocomplete="off" attribute only to discover that there wasn't one.
Why does Chrome not offer to autofill the email input in this form? This is a link to the site.. But this is the form that is blocking autocomplete on the email address.
<form method="post" class="form-horizontal">
<h1 class="paste-page-header">Log in</h1>
<div class="form-group">
<div class="col-md-24">
<label class="paste-input-label">Email</label>
<div class="paste-input-wrapper">
<input type="text" id="email" name="email" placeholder="Email" tabindex="1" required="true" class="paste-input sl_whiteout" autofocus="autofocus" maxlength="255">
</div>
</div>
</div>
<div class="form-group col-md-24">
<button role="login-button" type="submit" tabindex="2" class="paste-primary-button" data-loading-text="<i class='icon icon-spinner icon-spin'></i>" value="Log in">Next
</button>
</div>
<span class="paste-text">Don’t have an account yet? Sign up for free.</span>
<input inert="" readonly="true" type="password" id="password" name="password" tabindex="50" style="opacity: 0.02;" aria-label="This is a hidden password field for compatibility with password managers. Please ignore this field.">
<input type="hidden" name="g" value="/console/sms/dashboard?" class="sl_whiteout">
<input type="hidden" name="t" value="182b71c36e3bb0a0a788ab671fbe875c7b46602de5f49fb3e441645b8848a76a" class="sl_whiteout">
<input type="hidden" name="CSRF" value="2869689c41323f2456ec6558c8ee7f3e4c409eda3bbed69bf10228f752a293e4" class="sl_whiteout">
</form>
After you type your email address, it will allow you to autocomplete the password, it's just this field that is a problem. And I tried this:
> x = document.getElementById('email')
<input type=​"text" id=​"email" name=​"email" placeholder=​"Email" tabindex=​"1" required=​"true" class=​"paste-input sl_whiteout" autofocus=​"autofocus" maxlength=​"255">​
> x = document.getElementById('email')
x.autocomplete
''
So, they aren't disabling it with JS (at least not in any way that I can see.....
I'm asking so that I don't make this mistake on any of my sites and because I'm really curious how they pulled this off.

Chrome autocompletes wrong input

I have a strange issue on Chrome (75.0.3770.142). I have vue app with form and two text inputs with different names. When I try to autocomplete the first one it fills the second one instead (and the first input stays empty). I cannot reproduce it out of my application.
My component
<template>
<label class="wrapper" :data-error="validation && errors.first(name)" :class="{ error: errors && errors.first(name), label }">
<span class="label" v-if="label">{{label}}</span>
<div class="input" :class="{
'input--search': type === 'search'
}">
<input
v-if="validation"
:aria-label="ariaLabel"
v-shortkey.focus="shortKey"
:disabled="disabled"
:type="type"
:class="classes"
:value="value"
:name="name"
:placeholder="placeholder"
#search="reset"
#input="update"
v-validate="validation"
:autocomplete="autocomplete"
/>
<input
v-else
:aria-label="ariaLabel"
v-shortkey.focus="shortKey"
:disabled="disabled"
:type="type"
:class="classes"
:value="value"
:name="name"
:placeholder="placeholder"
#search="reset"
#input="update"
:autocomplete="autocomplete"
/>
<Icon class="icon" v-if="iconName && !value" :name="iconName" />
</div>
</label>
</template>
Form:
<template>
<form class="form" v-on:submit.prevent>
<slot />
<Input
v-if="isLabel && displayLabel"
class="label"
ref="label"
type="text"
:label="$t('subscriptions.new.label-placeholder')"
name="label"
:validation="{ required: true }"
:value="label"
#input="onLabelChange"
/>
<hr />
<Terms
v-if="!termsAccepted"
:value="terms"
#input="onTermsToggle"
/>
<Button
class="submit button-next"
submit
:disabled="nextDisabled"
#click="next"
>
{{ $t('subscriptions.new.next') }}
</Button>
</form>
</template>
and screen from Chrome
https://imgur.com/a/hMXVLYP
video:
https://imgur.com/a/gOwulXm
I am not familiar with Vue but you can try using input type as tel for telephone field with attributes like name and autocomplete with values as..
<input type="tel" name="phone" id="yourid" placeholder="+1-650-123-1234" autocomplete="tel">
Not setting autocomplete and incorrect input type for the field could be the reason for this behavior.
Hope this helps.

Chrome warning "[DOM] Password forms should have (optionally hidden) username fields for accessibility" in console even with hidden username field

When visiting the "reset password" route of my single-page app and looking at the Chrome browser console, I am greeted with the follwing warning:
[DOM] Password forms should have (optionally hidden) username fields for accessibility: (More info: goo.gl/9p2vKq)
Helpfully, the html of the form in question is also printed to the console in the next line, and quite clearly contains a hidden username field:
<form data-ember-action data-ember-action-436=​"436">​
<div class=​"form-group">
<label for=​"newpasswordone">​Password​</label>​
<input type=​"password" autocomplete=​"new-password" placeholder=​"Enter your new password" id=​"ember437" class=​"form-control ember-text-field ember-view" data-op-id=​"0">​
<label for=​"newpasswordtwo">​Password (again)​</label>
​<input type=​"password" autocomplete=​"new-password" placeholder=​"Re-enter your new password" id=​"ember438" class=​"form-control ember-text-field ember-view" data-op-id=​"1">​
<input type=​"hidden" name=​"username" autocomplete=​"username" value=​"a_b">
​</div>​
<button disabled type=​"submit" class=​"btn btn-default">​Reset password​</button>​​
</form>​
I tried some minor variations -- unhiding the username field, marking it readonly, moving it outside the div -- without affecting the warning.
How does Chrome expect to be served the username?
Problem occurs with Chrome 63 and 64.
I had the same problem. After some digging, I found that it needs to be an input element with the type text. By "optionally hidden" they mean that you may hide it with CSS.
If you just add an input with the name email or username chrome gives you another warning saying that input elements should have autocomplete attributes. So this is what I came up with to fix these errors:
<input
type="text"
name="email"
value="..."
autocomplete="username email"
style="display: none;"
>
You will need to manually render the actual username or email into the elements value attribute.
Also, keep in mind that inline styles are not a very good practice.
Use the hidden attribute instead of type="hidden"
<input hidden type="text" autocomplete="username" value="{{...}}">
I had this same situation.
Everything seemed be ok but I still got this verbose.
On my case helped me a relocate this userName input from end of form to begin of that.
It was my code before my changes:
<form id="changePass">
<div class='modal-dialog'>
<input type="password" class="form-control" id = "changePasswordOldPassword" autocomplete="current-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword" autocomplete="new-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword2" autocomplete="new-password"/>
<div class="modal-footer">
<button type="button" id="change-password-ok-button">Ok</button>
<button type ="button" data-dismiss="modal">Close</button>
</div>
</div>
<input id="userName" name="username" autocomplete="username" value="">
</form>
And this is current code:
<form id="changePass">
<input id="userName" name="username" autocomplete="username" value="">
<div class='modal-dialog'>
<input type="password" class="form-control" id = "changePasswordOldPassword" autocomplete="current-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword" autocomplete="new-password"/>
<input type="password" class="form-control" id = "changePasswordNewPassword2" autocomplete="new-password"/>
<div class="modal-footer">
<button type="button" id="change-password-ok-button">Ok</button>
<button type ="button" data-dismiss="modal">Close</button>
</div>
</div>
</form>
you must put the input tag inside another tag for example:
<form action="">
<div>
<input type="text" autocomplete="username">
</div>
<div>
<input type="password" autocomplete="password">
</div>
<div>
<input type="password" autocomplete="password">
</div>
I had this same situation in VueJs when i use rendering conditional v-if v-else and i try put input tag inside new tag and it's work for me
Though I know that this question is quite old but thought maybe it may be useful for someone .I also faced the same issue with my React app update user password and this worked for me just above the password fields without label.Excuse me for writing the React way .
<input hidden type='text' name='email' autoComplete='email' />
Basic usage :-
<form>
<input hidden type='text' name='email' autoComplete='email' />
<label htmlFor="oldPass">Enter your current password</label>
<input id="oldPass" type="password" />
<label htmlFor="newPass">Enter your new password</label>
<input id="newPass" type="password" />
</form>
After reading Jonas comment I rebuilt the project and the warning went away
I had the same warning showing in the console and this is how I fixed it:
<input hidden autocomplete="username" name="username" type="text" value="{{..}}"/>
<input hidden autocomplete="email" name="email" type="text" value="{{..}}"/>

Button html triggering active keyboard on IOS?

We have built a site with a login page - login page is a simple form in field sets - annoyingly when using an iPad the keyboard is triggered whenever pressing the button - it stays active as the next page is loaded - i can understand why - following is the form code - is there any way to disable this functionality?
<section>
<h3>Login</h3>
<form method="post" action="/Login" novalidate="novalidate" _lpchecked="1"> <fieldset>
<label class="ui-front legend icon-img-inside">
<label for="FormModel_UserName">User Name</label>
<input type="text" value="" name="FormModel.UserName" id="FormModel_UserName" data-val-required="Please provide your User Name" data-val="true" aria-required="true" aria-describedby="FormModel_UserName-error" class="input-validation-error" aria-invalid="true">
<span data-valmsg-replace="true" data-valmsg-for="FormModel.UserName" class="field-validation-error"><span id="FormModel_UserName-error" class="">Please provide your User Name</span></span>
<img alt="Icon: Person" src="/css/img/icons/icon-user.svg">
</label>
</fieldset>
<fieldset>
<label class="ui-front legend icon-img-inside">
<label for="FormModel_Password">Password</label>
<input type="password" name="FormModel.Password" id="FormModel_Password" data-val-required="Please provide your Password" data-val="true" aria-required="true" class="input-validation-error" aria-describedby="FormModel_Password-error">
<span data-valmsg-replace="true" data-valmsg-for="FormModel.Password" class="field-validation-error"><span id="FormModel_Password-error" class="">Please provide your Password</span></span>
<img alt="Icon: Pencil" src="/css/img/icons/icon-pencil.svg">
</label>
</fieldset>
<div data-valmsg-summary="true" class="validation-summary-errors"><ul> <li>Please provide your User Name</li><li>Please provide your Password</li> </ul></div> <fieldset>
<button class="button" name="submit" type="submit">
<i class="key"></i>
<span>Login</span>
</button>
</fieldset>
<!-- Javascript detection -->
<span class="result-login" id="result"></span>
You could try to disable native, default submit process and do submiting with js,, something like this:
document.getElementsByClassName('button')[0].onclick = function(e){
e.preventDefault();
document.getElementById('frm1').submit();
}
see the code here, I changed some tag names, look the html pane also..: http://codepen.io/mkdizajn/pen/EgmPQR?editors=1010
I can't see this live and test but I hope that helps..

HTML Text label misplaced when in line validation appears

I have a simple form with a date validation which works fine:
The problem is that when the validation kicks in, the "End Date" label gets misplaced as you can see (is above the date field box/calendar):
The code related is the following (it's just a form):
<form name="senstageaddform">
<div class="form-element">
<label for="ed_senStartDate" class="text-label">
{{i18n "EDUCATION_SEN_START_DATE"}} <span class="required">*</span>
</label>
<input type="text" class="date standard-text-field" maxlength="16" id="ed_senStartDate" name="startDate"/>
</div>
<div class="form-element">
<label for="ed_senEndDate" class="text-label">{{i18n "EDUCATION_SEN_END_DATE"}}</label>
<input type="text" class="date standard-text-field" maxlength="16" id="ed_senEndDate" name="endDate"/>
</div>
</form>
Is there any way to "pack" the form or any way to stop this happening?
Any hint please?
Thanks everyone