Skip to content
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

Merged
merged 8 commits into from
Apr 8, 2019

Conversation

tomnez
Copy link
Contributor

@tomnez tomnez commented Apr 2, 2019

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-multiline-maxlen

Character count with no max length:

character-count-multiline

Press and hold spinner:

spinner-hold

@tomnez tomnez self-assigned this Apr 2, 2019
@tomnez tomnez requested review from vladucu and andrewpye April 2, 2019 18:29
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);
Copy link
Contributor Author

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.

Copy link
Member

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 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.

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 🤷‍♂️

Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Member

@andrewpye andrewpye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why the native spinner is showing here?

image

It doesn't seem to appear on the React implementation... 😬

Otherwise this looks pretty sick!

let { input, focused } = this.getProperties('input', 'focused');
normalizedValue: computed('value', function() {
let value = this.get('value');
return value !== null ? value : '';
Copy link
Member

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.

Copy link
Member

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() {
Copy link
Member

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 : '';
}),
Copy link
Member

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`;
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readOnly?

},

return classNames.join(' ');
}),
Copy link
Member

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);
Copy link
Member

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 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.

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;
Copy link
Member

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)
Copy link
Member

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 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tomnez tomnez requested a review from andrewpye April 3, 2019 17:27
Copy link
Member

@vladucu vladucu left a 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 : '';
Copy link
Member

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
Copy link
Member

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 */) {},
Copy link
Member

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 tomnez requested a review from vladucu April 5, 2019 15:27
@vladucu
Copy link
Member

vladucu commented Apr 5, 2019

Any idea why the native spinner is showing here?
image
It doesn't seem to appear on the React implementation... 😬

@tomnez any luck with this ^ ?

@tomnez
Copy link
Contributor Author

tomnez commented Apr 5, 2019

@vladucu ah missed that too, I'll look into it.

@vladucu
Copy link
Member

vladucu commented Apr 5, 2019

thx!

Copy link
Member

@andrewpye andrewpye left a 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 👍

@tomnez
Copy link
Contributor Author

tomnez commented Apr 8, 2019

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.

@tomnez tomnez merged commit 27b767f into update/polaris-v3.10.0 Apr 8, 2019
@delete-merged-branch delete-merged-branch bot deleted the update/textfield-v3.10.0 branch April 8, 2019 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants