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

Upgrade v2.11.0 choicelist #193

Merged
merged 11 commits into from
Oct 12, 2018
Merged

Upgrade v2.11.0 choicelist #193

merged 11 commits into from
Oct 12, 2018

Conversation

tomnez
Copy link
Contributor

@tomnez tomnez commented Oct 8, 2018

Finishes #188

Diff here

@tomnez tomnez self-assigned this Oct 8, 2018
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.

Great start, although I think we're missing an id attribute on the fieldset and I feel there's a little bit of room for making prop names more understandable

/**
* @private
*/
hasError: bool('error'),
Copy link
Member

Choose a reason for hiding this comment

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

Not sure it's a big deal, but the React implementation has this as error != null so maybe we should look at mimicking that behaviour here?

*
* @property error
* @public
* @type {string|component}
Copy link
Member

Choose a reason for hiding this comment

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

These are from a time when I was young and foolish so I know this isn't your doing, but these types should be capitalised since they're class names

* @property error
* @public
* @type {string|component}
* @default false
Copy link
Member

Choose a reason for hiding this comment

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

This @default doesn't match the actual default value 😉

/**
* @private
*/
finalNameError: computed('finalName', 'error', function() {
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if this prop name is a bit unclear - what do you think about using something like ariaDescribedBy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I'm going to also update hasError to ariaInvalid since it's only used for the aria-invalid attribute binding 👍

return null;
}

return `${this.get('finalName')}Error`;
Copy link
Member

Choose a reason for hiding this comment

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

We have an existing util for generating this, maybe worth using that here? 🤷‍♂️

addon/components/polaris-choice-list.js Show resolved Hide resolved
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.

Tom, nice!!

Almost there, mostly Andy's comment and some minor ones on my end....was thinking, while we're here what do you think of cleaning up tests too: no longer use ember-native-dom-helpers (use same stuff provided by @ember/test-helpers), use test selectors instead of classes

CHANGELOG.md Outdated
@@ -8,7 +8,7 @@
- [#187](https://github.com/smile-io/ember-polaris/pull/187) [FEATURE] Add `disabled` attribute to `polaris-choice`
- [#185](https://github.com/smile-io/ember-polaris/pull/185) [FEATURE] Update `polaris-button` to accept components for `icon` value
- [#191](https://github.com/smile-io/ember-polaris/pull/191) [ENHANCEMENT] Update `polaris-layout/annotated-section` styling to match Polaris v2.11.0

- [#193](https://github.com/smile-io/ember-polaris/pull/193) [FEATURE] Update `polaris-choice-list` to render `error` and `aria` attributes
Copy link
Member

Choose a reason for hiding this comment

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

this is not a new feature 😜...update? (a few others here are marked as feature when they shouldn't, ex: button)


attributeBindings: [
'hasError:aria-invalid',
'finalNameError:aria-described-by',
Copy link
Member

Choose a reason for hiding this comment

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

should this be aria-describedby?

@tomnez
Copy link
Contributor Author

tomnez commented Oct 10, 2018

@andrewpye @vladucu updated, had some conflicts so github might not be showing "since you last viewed" - the edits are all in this commit if you want to check it on its own.

ariaDescribedBy: computed('finalName', 'error', function() {
if (isNone(this.get('error'))) {
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

This check doesn't seem to be in the original, any reason for adding it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh no, I think this is a combination of my brain going rogue as well as a hilarious misunderstanding of what aria-describedby is for 🤦‍♂️

@tomnez
Copy link
Contributor Author

tomnez commented Oct 11, 2018

@vladucu @andrewpye updated with edits, as well as updated the test file to use built-in helpers and ember-test-selectors 👍

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.

I think this is all good @tomnez! 🔥

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.

just a couple of small comments re testing...otherwise looks good to me

@@ -9,6 +9,7 @@
}}
<span class="Polaris-Checkbox {{if error "Polaris-Checkbox--error"}}">
<input
data-test-polaris-checkbox-input
Copy link
Member

Choose a reason for hiding this comment

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

to be consistent with other places....let's rename this to omit polaris, just data-test-checkbox-input

@@ -20,3 +20,12 @@
</li>
{{/each}}
</ul>

{{#if error}}
<div data-test-polaris-choice-list-error class="Polaris-ChoiceList__ChoiceError">
Copy link
Member

Choose a reason for hiding this comment

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

same, remove polaris

addon/components/polaris-choice-list.js Show resolved Hide resolved
@@ -66,4 +66,6 @@ export default Component.extend({
* @public
*/
disabled: null,

'data-test-polaris-choice': true,
Copy link
Member

Choose a reason for hiding this comment

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

same as the comment above


const choices = findAll(choiceSelector);
const radioInputs = findAll(radioInputSelector);
assert.equal(choices.length, 3, 'renders three choices');
Copy link
Member

Choose a reason for hiding this comment

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

you can just do `assert.dom(coiceSelector).exists({ count: 3 }, 'renders three choices');

assert.equal(choices.length, 3, 'renders three choices');

// Check the choices.
let choice = choices[0];
Copy link
Member

Choose a reason for hiding this comment

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

no need to use these anymore, you can just use assert.dom(${choiceSelector}:nth-child(1))` to target first item and so on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The nth selectors don't work in these cases because the choice selectors aren't all children of the same parent, so the test will only ever find nth-child(1) or nth-of-type(1) and then bork on trying to find the 2nd or 3rd, etc.

assert
.dom(choice)
.hasText('First option', 'first choice - has correct label text');
let radioInput = radioInputs[0];
Copy link
Member

Choose a reason for hiding this comment

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

similar as above for the input

@tomnez
Copy link
Contributor Author

tomnez commented Oct 12, 2018

@vladucu made most of your edits, I updated selectors where I could but left a comment regarding the nth selectors.

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.

cool, don't think it's that important as long as we test it, I just personally like more working with the dom API

PS: the nth stuff likely didn't worked because you had to scope to the parent

@tomnez tomnez merged commit 552635a into dev Oct 12, 2018
@delete-merged-branch delete-merged-branch bot deleted the upgrade-v2.11.0-choicelist branch October 12, 2018 19:15
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