-
Notifications
You must be signed in to change notification settings - Fork 14
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(sbb-tag, sbb-tag-group): implement native form support #3379
base: main
Are you sure you want to change the base?
Conversation
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 work, some comment added
2cc39e1
to
f300b36
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.
Thanks for your work! I think the solution is basically ok. Currently I'm concerned about the a11y snapshot tests which had to be changed in a for me negative way. But I don't see the cause for it.
@@ -42,7 +42,7 @@ $active: ':active, [data-active]'; | |||
} | |||
|
|||
// Active state | |||
:host([checked]) { | |||
:host([aria-pressed='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.
I'd recommend to handle it the same way like for the checkbox by a "data-checked".
@@ -84,18 +81,15 @@ snapshots["sbb-tag-group renders A11y tree Chrome"] = | |||
"children": [ | |||
{ | |||
"role": "button", | |||
"name": "First tag", | |||
"pressed": false | |||
"name": "First tag" |
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 am worried that the pressed state is not reflected anymore. Do you know the cause?
@@ -110,15 +104,15 @@ snapshots["sbb-tag-group renders A11y tree Firefox"] = | |||
"name": "", | |||
"children": [ | |||
{ | |||
"role": "toggle button", | |||
"role": "button", |
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.
Hmm it doesn't seem to be recognized as toggle button anymore. Could this be preserved?
const tagTemplate = (label: string, checked = false): TemplateResult => html` | ||
<sbb-tag ?checked=${checked} value=${label} amount="123" icon-name="pie-small"> | ||
const tagTemplate = (label: string, checked = false, name = 'name'): TemplateResult => html` | ||
<sbb-tag name="${name}" ?checked=${checked} value=${label} amount="123" icon-name="pie-small"> |
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.
nitpicky, but in non-form examples, the name doesn't make any sense. So I recommend to not default to 'name' but have it "undefined", and then use:
<sbb-tag name="${name}" ?checked=${checked} value=${label} amount="123" icon-name="pie-small"> | |
<sbb-tag name=${name || nothing} ?checked=${checked} value=${label} amount="123" icon-name="pie-small"> |
@forceType() | ||
@property({ reflect: true, type: Boolean }) | ||
public accessor checked: boolean = false; | ||
@property({ reflect: false, type: Boolean }) |
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.
coercing the boolean got lost during change. but you can use !!value
public accessor checked: boolean = false; | ||
@property({ reflect: false, type: Boolean }) | ||
public set checked(value: boolean) { | ||
this._checked = 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.
maybe setting ariaPressed should come here as well? or updateformValue goes into willupdate?
Preflight Checklist
Issue
This PR Closes #3157
Pull request checklist
Please check if your PR fulfills the following requirements:
See Review Guidelines for more information what is checked during review process.
Changes
Changes in this pull request:
Browsers
I tested the build on the following browsers:
Screen readers
I tested the build on the following browsers:
Pull request type
Please check the type of change your PR introduces:
Does this introduce a breaking change?
Other information