-
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
Update textfield to Polaris v3.10.0 #310
Conversation
if (input && focused) { | ||
// TODO this _seems_ to work in Polaris without the row below, but not for us (it does not apply focus class) | ||
// look what's here....though this seems to do the job for now | ||
this.set('focus', true); |
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.
This was removed in favor of the focus
computed property below now that the react implementation has updated their code to check the previous and current value of focused
in order to determine whether or not to focus or blur the field.
We can't really do the same thing and call blur
on didUpdateAttrs
because there's a chance other attributes have been updated while focused
is set to false
, and we wouldn't want to accidentally blur the field as the user is typing just because the initial value of focused
was false
.
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 can't really do the same thing and call
blur
ondidUpdateAttrs
because there's a chance other attributes have been updated whilefocused
is set tofalse
, and we wouldn't want to accidentally blur the field as the user is typing just because the initial value offocused
wasfalse
.
Not sure I follow this 😬 Can't we track wasFocused
internally and call blur
/focus
as appropriate from didUpdateAttrs
? If focused
changes, then we should still be obeying it, and if you're worried about "accidentally blurring the field as the user is typing", that's on the host app to pass sensible property values 🤷♂️
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 guess we can make some bootleg version of wasFocused
. The original buggyness I was seeing wasn't a host app being irresponsible, it was that you couldn't type without the field blur-ing unless you explicitly passed focused=true
, which shouldn't happen. I'll see about making our own wasFocused
.
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.
Yeah, I don't see why this shouldn't work with wasFocused
(we're doing similar things in some other components already)
fc92356
to
814eb3c
Compare
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.
let { input, focused } = this.getProperties('input', 'focused'); | ||
normalizedValue: computed('value', function() { | ||
let value = this.get('value'); | ||
return value !== null ? value : ''; |
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.
Might be worth explicitly matching the React implementation and using !=
here so that this catches undefined
values etc.
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.
^this
// look what's here....though this seems to do the job for now | ||
this.set('focus', true); | ||
input.focus(); | ||
characterCount: computed('normalizedValue.length', function() { |
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.
This should maybe be readOnly
normalizedValue: computed('value', function() { | ||
let value = this.get('value'); | ||
return value !== null ? value : ''; | ||
}), |
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.
Can this be readOnly
?
return maxLength | ||
? `${characterCount} characters of ${maxLength} used` | ||
: `${characterCount} characters`; | ||
}), |
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.
readOnly
?
}, | ||
|
||
return classNames.join(' '); | ||
}), |
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.
readOnly
?
if (input && focused) { | ||
// TODO this _seems_ to work in Polaris without the row below, but not for us (it does not apply focus class) | ||
// look what's here....though this seems to do the job for now | ||
this.set('focus', true); |
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 can't really do the same thing and call
blur
ondidUpdateAttrs
because there's a chance other attributes have been updated whilefocused
is set tofalse
, and we wouldn't want to accidentally blur the field as the user is typing just because the initial value offocused
wasfalse
.
Not sure I follow this 😬 Can't we track wasFocused
internally and call blur
/focus
as appropriate from didUpdateAttrs
? If focused
changes, then we should still be obeying it, and if you're worried about "accidentally blurring the field as the user is typing", that's on the host app to pass sensible property values 🤷♂️
}), | ||
|
||
focus: computed('focused', function() { | ||
return this.get('focused') || false; |
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.
lol, this is weird logic but I appreciate that it's in the React implementation 🤷♂️ Anyhoo, how 'bout making this readOnly
too?
|
||
this.set( | ||
'buttonPressTimer', | ||
window.setTimeout(onChangeInterval, interval) |
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 wonder if we're better off using runloop-compatible timer functions here 🤔 This is probably fine in React-land but it's making me nervous in Ember-world 😅
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.
Some minor comments & I think we missed updating ariaDescribedBy
CP....but almost there
let { input, focused } = this.getProperties('input', 'focused'); | ||
normalizedValue: computed('value', function() { | ||
let value = this.get('value'); | ||
return value !== null ? value : ''; |
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.
^this
@@ -45,7 +45,7 @@ | |||
minlength=minLength | |||
maxlength=maxLength | |||
spellcheck=spellCheck | |||
value=value | |||
value=normalizedValue |
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 should also pass step
here?
|
||
onMouseDown() {}, | ||
|
||
onMouseUp(/* onChange */) {}, |
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.
nit: onMouseDown
gets invoked with onChange
, not onMouseUp
😜
@tomnez any luck with this ^ ? |
@vladucu ah missed that too, I'll look into it. |
thx! |
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.
Giving this the green light to merge into the epic branch, where it'll be easier to check out the number
spinner issue to see whether it's a dummy app thing or something else 👍
I'm having wacky node issues with linking the host apps to this branch, we suspect this is just a dummy app issue since the React markup also displays the same problem when copied into the dummy app so we're going to merge and make a note to double check this on a real app. |
Adds a new
showCharacterCount
attribute as well as methods for holding down the buttons in the number spinners to slowly increment/decrement the current number value.Character count with max length:
Character count with no max length:
Press and hold spinner: