-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: autofill solution #599
Conversation
🚀 Latest successful build of the PR deployed here. 🚀 |
::slotted(input) { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
padding: 0 16px; | ||
box-sizing: border-box; | ||
border-radius: var(--border-radius); | ||
border: none; | ||
background: transparent; | ||
outline: none; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you suggest to state with the current implementation (I mean the picture you show is not happening in the brach as it is, right)?
ran into this trick couple of times 👉 https://github.com/matteobad/detect-autofill/blob/master/src/detect-autofill.js |
Oh man, please no! Just compare the current solution - all works and almost
zero code/css, and all those hack around! Why get ourselves in trouble?
…On Fri, 22 Jan 2021, 9:58 yinon, ***@***.***> wrote:
ran into this trick couple of times 👉
https://github.com/matteobad/detect-autofill/blob/master/src/detect-autofill.js
interesting?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#599 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABG2SNPW3LBUGAVEVRUZ2X3S3EVZXANCNFSM4WMRCNLA>
.
|
fe.onblur = this.onInputBlur.bind(this); | ||
|
||
// attributes/properties | ||
fe.setAttribute('id', this.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a bit problematic? We're going to have the same ID both on the custom-element
as well as on the input
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this too, while doing that. Concern and my thoughts - sharing to put it here and then up to your take guys:
- input element having
id
is somewhat important part of input (for label association, aria label association, sometimes seems to participate in form association and autofill) id
should be unique, this is pain- to transfer
id
from parent to child (remove on parent) is no go, since it's intervention into consumer's domain - duplicate
id
IS ugly, no brainer, but not breaking things and seemings won't harm
I'm actually inclined now to remove this and add when absolutely proven needed later.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said that autofill takes id
into account - but it also takes name
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, right, so presumable we can stay with name
meanwhile. Just see this and pay attention to that wording: user again main require name
and/or id
attribute.
protected renderInput(): TemplateResult { | ||
this.updateInputElement(); | ||
return html` | ||
<div class="mdc-text-field__input"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for? Is it going to be used by someone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need it to preserve the effect of that mdc-text-field__input
class - spacing, elements positioning around etc.
This is the simplest way to actually preserve all the MWC heavy lifting with that part.
…nto autofill-solution
…ll-solution # Conflicts: # common/foundation/test/autofocus.test.js
…nto autofill-solution
…nto autofill-solution
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
fe.onfocus = this.onInputFocus.bind(this); | ||
fe.onblur = this.onInputBlur.bind(this); | ||
|
||
// attributes | ||
setAttributeIfDefined('id', this.id, fe); | ||
setAttributeIfDefined('name', this.name, fe); | ||
setAttributeIfDefined('type', this.type, fe); | ||
setAttributeIfDefined('form', this.form, fe); | ||
setAttributeIfDefined('placeholder', this.placeholder, fe); | ||
|
||
setAttributeIfDefined('min', this.min, fe); | ||
setAttributeIfDefined('max', this.max, fe); | ||
setAttributeIfDefined('step', this.step, fe); | ||
setAttributeIfDefined('size', this.size, fe); | ||
|
||
const autoCapOrNone = this.autocapitalize ? this.autocapitalize : undefined; | ||
const minOrNone = this.minLength === -1 ? undefined : this.minLength; | ||
const maxOrNone = this.maxLength === -1 ? undefined : this.maxLength; | ||
setAttributeIfDefined('autocapitalize', autoCapOrNone, fe); | ||
setAttributeIfDefined('minlength', minOrNone, fe); | ||
setAttributeIfDefined('maxlength', maxOrNone, fe); | ||
setAttributeIfDefined('pattern', this.pattern, fe); | ||
setAttributeIfDefined('inputmode', this.inputMode, fe); | ||
|
||
addAttributeByCondition('disabled', this.disabled, fe); | ||
addAttributeByCondition('readonly', this.readOnly, fe); | ||
addAttributeByCondition('required', this.required, fe); | ||
|
||
const ariaLabel = shouldRenderHelperText ? 'helper-text' : undefined; | ||
const ariaError = | ||
this.validationMessage && !this.isUiValid ? 'helper-text' : undefined; | ||
setAttributeIfDefined('aria-controls', ariaLabel, fe); | ||
setAttributeIfDefined('aria-describedby', ariaLabel, fe); | ||
setAttributeIfDefined('aria-errortext', ariaError, fe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouchs ;)
const [formElement] = addElement( | ||
createElementInForm(fieldName, fieldValue) | ||
); | ||
const [formElement] = createElementInForm(fieldName, fieldValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [formElement] = createElementInForm(fieldName, fieldValue); | |
const [formElement] = addElement(createElementInForm(fieldName, fieldValue)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll push one small change
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
No description provided.