-
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
Upgrade v2.11.0 choicelist #193
Conversation
4ca288a
to
c56e86c
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.
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'), |
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.
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} |
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.
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 |
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 @default
doesn't match the actual default value 😉
/** | ||
* @private | ||
*/ | ||
finalNameError: computed('finalName', 'error', 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.
Wondering if this prop name is a bit unclear - what do you think about using something like ariaDescribedBy
?
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.
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`; |
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 have an existing util for generating this, maybe worth using that here? 🤷♂️
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.
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 |
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 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', |
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.
should this be aria-describedby
?
c56e86c
to
752389a
Compare
@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; | ||
} |
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 check doesn't seem to be in the original, any reason for adding it?
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.
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 🤦♂️
@vladucu @andrewpye updated with edits, as well as updated the test file to use built-in helpers and |
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 think this is all good @tomnez! 🔥
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.
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 |
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.
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"> |
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.
same, remove polaris
@@ -66,4 +66,6 @@ export default Component.extend({ | |||
* @public | |||
*/ | |||
disabled: null, | |||
|
|||
'data-test-polaris-choice': 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.
same as the comment above
|
||
const choices = findAll(choiceSelector); | ||
const radioInputs = findAll(radioInputSelector); | ||
assert.equal(choices.length, 3, 'renders three choices'); |
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 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]; |
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.
no need to use these anymore, you can just use assert.dom(
${choiceSelector}:nth-child(1))` to target first item and so on
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.
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]; |
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.
similar as above for the input
@vladucu made most of your edits, I updated selectors where I could but left a comment regarding the |
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.
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
Finishes #188
Diff here