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 autocomplete grid #2512

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

Conversation

DavideMininni-Fincons
Copy link
Contributor

@DavideMininni-Fincons DavideMininni-Fincons commented Mar 21, 2024

Preflight Checklist

Issue

This PR Closes #1945

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:

  • new sbb-autocomplete-grid component added, with related components:
    • sbb-autocomplete-grid-optgroup, similar to native optgroup
    • sbb-autocomplete-grid-row, which acts as a container for both option and actions
    • sbb-autocomplete-grid-option, similar to native option
    • sbb-autocomplete-grid-actions, which acts as a container for button
    • sbb-autocomplete-grid-button
  • the autocomplete, optgroup and option components have been refactored using a base class

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

@DavideMininni-Fincons DavideMininni-Fincons linked an issue Mar 21, 2024 that may be closed by this pull request
10 tasks
@github-actions github-actions bot temporarily deployed to preview-pr2512 March 21, 2024 09:33 Inactive
@DavideMininni-Fincons DavideMininni-Fincons marked this pull request as ready for review March 21, 2024 10:15
@github-actions github-actions bot temporarily deployed to preview-pr2512 March 21, 2024 16:11 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Mar 22, 2024

Codecov Report

Attention: Patch coverage is 98.09524% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 93.24%. Comparing base (e6397df) to head (ee4d5ec).
Report is 66 commits behind head on main.

❗ Current head ee4d5ec differs from pull request most recent head b77607c. Consider uploading reports for the commit b77607c to get more accurate results

Files Patch % Lines
src/components/autocomplete/autocomplete.ts 92.85% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2512      +/-   ##
==========================================
+ Coverage   93.18%   93.24%   +0.05%     
==========================================
  Files         316      316              
  Lines       25389    24613     -776     
  Branches     2063     1986      -77     
==========================================
- Hits        23660    22950     -710     
+ Misses       1696     1631      -65     
+ Partials       33       32       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot temporarily deployed to preview-pr2512 March 25, 2024 09:02 Inactive
@github-actions github-actions bot temporarily deployed to preview-pr2512 March 25, 2024 16:06 Inactive
@github-actions github-actions bot temporarily deployed to preview-pr2512 March 26, 2024 08:55 Inactive
@github-actions github-actions bot temporarily deployed to preview-pr2512 March 26, 2024 10:48 Inactive
@DavideMininni-Fincons DavideMininni-Fincons changed the title feat: sbb autocomplete grid [WIP] feat: sbb autocomplete grid Mar 26, 2024
@DavideMininni-Fincons DavideMininni-Fincons added the pr: peer review required A peer review is required for this pull request label Mar 26, 2024
Copy link
Contributor

@TomMenga TomMenga left a comment

Choose a reason for hiding this comment

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

Good job as usual
Only a partial review ( around half of it ) 😵‍💫

@github-actions github-actions bot temporarily deployed to preview-pr2512 March 28, 2024 16:30 Inactive
Copy link
Contributor

@TomMenga TomMenga left a comment

Choose a reason for hiding this comment

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

Hello, few things to fix

@github-actions github-actions bot temporarily deployed to preview-pr2512 April 3, 2024 12:51 Inactive
@jeripeierSBB jeripeierSBB added the pr: lead review required A lead review is required for this pull request label Apr 8, 2024
Copy link
Contributor

@TomMenga TomMenga left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@TomMenga TomMenga removed the pr: peer review required A peer review is required for this pull request label Apr 8, 2024
…-grid

# Conflicts:
#	src/elements/autocomplete/autocomplete.spec.ts
#	src/elements/button/mini-button/mini-button.ts
#	src/elements/option/optgroup/optgroup.ts
#	src/elements/option/option/option.ts
@github-actions github-actions bot temporarily deployed to pr2512 July 2, 2024 14:34 Inactive
@github-actions github-actions bot temporarily deployed to pr2512 July 3, 2024 13:16 Inactive
@github-actions github-actions bot temporarily deployed to pr2512 July 3, 2024 14:48 Inactive
@github-actions github-actions bot temporarily deployed to pr2512 July 4, 2024 12:29 Inactive
@DavideMininni-Fincons
Copy link
Contributor Author

Note for reviewers:
apparently, the autocomplete behavior (add bold style to options that match the typed text) was not working anymore due some changes related to SSR.

A fix was made in the commit 'fix: enable autocomplete behavior' 89538b1 but since i'm not fully aware of what exactly is rendered in SSR, the change should be reviewed.

@github-actions github-actions bot temporarily deployed to pr2512 July 4, 2024 15:23 Inactive
Copy link
Contributor

@kyubisation kyubisation left a comment

Choose a reason for hiding this comment

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

Nice work! 😃
Some minor nitpicks, but there is an issue with the mini button base.
After that it should be good to merge!

);

/** Observe changes on data attributes and set the appropriate values. */
private _onOptionAttributesChange(mutationsList: MutationRecord[]): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick; This could probably be inlined, as it is only used in the observer.


public constructor() {
super();
new SbbSlotStateController(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick; You could now use the slotState decorator.

/**
* Used to dispatch a click event when users interact with the button via keyboard (the component does not receive focus).
*/
public dispatchClick(event: KeyboardEvent): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether this needs to be a public method on this class. Could we not just dispatch a click event from the autocomplete grid, where this method is called from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As usual, the click on the ac-grid-button emits a click event with the button component as a target;
I could move this method in the ac-grid, however this will cause to emit a forced click event on keyboard selection with the ac-grid as a target, even if the 'visual-focus' is on the button

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I fully understand.
My suggestion would be to move the dispatch click event logic to the grid (or somewhere re-usable?), but still dispatch the event on the grid button in the selection via keyboard scenario.
Could you elaborate again?

) as SbbAutocompleteGridOptionElement[];
}

private get _buttons(): SbbAutocompleteGridButtonElement[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick; Could be inlined.

@@ -0,0 +1,78 @@
The `sbb-optgroup` is a component used to group more [sbb-autocomplete-grid-option](/docs/elements-sbb-autocomplete-grid-sbb-autocomplete-grid-option--docs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `sbb-optgroup` is a component used to group more [sbb-autocomplete-grid-option](/docs/elements-sbb-autocomplete-grid-sbb-autocomplete-grid-option--docs)
The `sbb-autocomplete-grid-optgroup` is a component used to group more [sbb-autocomplete-grid-option](/docs/elements-sbb-autocomplete-grid-sbb-autocomplete-grid-option--docs)

}
};

private _dispatchClickEvent = (event: KeyboardEvent): void => {
protected dispatchClickEvent = (event: KeyboardEvent): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is no longer needed. If this functionality is needed externally, we can extract it as a function or as a static method.


@slotState()
export abstract class SbbMiniButtonBaseElement extends SbbNegativeMixin(
SbbIconNameMixin(SbbButtonBaseElement),
Copy link
Contributor

Choose a reason for hiding this comment

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

We must never import from outside the core directory from inside the core directory.
I would suggest moving this base element to the mini button.
What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: a11y review approved Pull request has been approved by a a11y review pr: lead review required A lead review is required for this pull request pr: peer review approved Pull request has been approved by a peer review pr: ux review approved Pull request has been approved by a ux review pr: visual review required preview-available visual-regression-diff-available
Projects
None yet
Development

Successfully merging this pull request may close these issues.

story(sbb-autocomplete-grid): initial implementation
6 participants