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

feat(sbb-tag, sbb-tag-group): implement native form support #3379

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MarioCastigliano
Copy link
Contributor

Preflight Checklist

Issue

This PR Closes #3157

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

See Review Guidelines for more information what is checked during review process.

Changes

Changes in this pull request:

  • tag-group now supports form support, and operates like a checkbox-group

Browsers

I tested the build on the following browsers:

  • Firefox Desktop
  • Chrome Desktop
  • Edge Desktop
  • Safari Desktop
  • Chrome Mobile
  • Safari Mobile

Screen readers

I tested the build on the following browsers:

  • JAWS Firefox Desktop
  • JAWS Chrome Desktop
  • NVDA Firefox Desktop
  • NVDA Chrome Desktop
  • VoiceOver Safari Desktop
  • VoiceOver Chrome Desktop
  • VoiceOver Safari Mobile
  • Android Accessibility Suite Chrome Mobile

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot requested a deployment to pr3379 January 31, 2025 15:50 In progress
@github-actions github-actions bot temporarily deployed to pr3379-diff January 31, 2025 15:50 Inactive
@MarioCastigliano MarioCastigliano marked this pull request as ready for review February 3, 2025 08:47
@MarioCastigliano MarioCastigliano self-assigned this Feb 3, 2025
@github-actions github-actions bot added the pr: peer review required A peer review is required for this pull request label Feb 3, 2025
@github-actions github-actions bot temporarily deployed to pr3379 February 3, 2025 09:10 Inactive
@github-actions github-actions bot temporarily deployed to pr3379-diff February 3, 2025 09:10 Inactive
Copy link
Contributor

@DavideMininni-Fincons DavideMininni-Fincons left a 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

src/elements/tag/tag/tag.scss Show resolved Hide resolved
src/elements/tag/tag-group/tag-group.spec.ts Outdated Show resolved Hide resolved
src/elements/tag/tag-group/readme.md Show resolved Hide resolved
@jeripeierSBB jeripeierSBB added the pr: lead review required A lead review is required for this pull request label Feb 12, 2025
Copy link
Contributor

@jeripeierSBB jeripeierSBB left a 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']) {
Copy link
Contributor

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"
Copy link
Contributor

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",
Copy link
Contributor

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">
Copy link
Contributor

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:

Suggested change
<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 })
Copy link
Contributor

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diff-available pr: lead review required A lead review is required for this pull request pr: peer review required A peer review is required for this pull request pr: visual review required preview-available target: 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

story(sbb-tag-group): implement native form support
3 participants