Skip to content

Update Lookup for SLDS2 #482

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

Open
wants to merge 33 commits into
base: support-slds-2
Choose a base branch
from

Conversation

msmx-mnakagawa
Copy link
Collaborator

@msmx-mnakagawa msmx-mnakagawa commented Jun 5, 2025

What I did

  • Lookup
    • update markups significantly
    • improve a11y
  • Spinner
    • add a layout prop
    • add an x-small size
  • Icon
    • add an xx-small size

Reference

https://v1.lightningdesignsystem.com/components/lookups/

@msmx-mnakagawa msmx-mnakagawa self-assigned this Jun 5, 2025
Copy link

reg-suit bot commented Jun 5, 2025

reg-suit detected visual differences.

Check this report, and review them.

🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵

What do the circles mean? The number of circles represent the number of changed images.
🔴 : Changed items, ⚪ : New items, ⚫ : Deleted items, and 🔵 Passed items

How can I change the check status? If reviewers approve this PR, the reg context status will be green automatically.

@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 5, 2025 06:49
@msmx-mnakagawa msmx-mnakagawa mentioned this pull request Jun 5, 2025
42 tasks
- add SLDS-compliant combobox markup structure
- implement basic aria attributes (role, aria-expanded, aria-haspopup, etc.)
- add keyboard navigation (arrow keys, Enter, Escape)
- support search functionality with dropdown display
- include listHeader and listFooter support
- add loading state display
- maintain existing API compatibility for basic features
- temporarily comment out future features in stories to avoid type errors
- add unified a11y ID generation (labelId, scopeId)
- implement proper label-input association with FormElement
- add common a11y props (ariaLabelledBy, ariaControls, ariaHaspopup)
- improve ID generation with fallbackId pattern
- enhance WAI-ARIA compliance for better screen reader support
- add scope-related props (scopes, targetScope, onScopeSelect, etc.)
- implement scope state management with controlled values
- add scope selection UI with icon-only display (slds-has-icon-only)
- implement scope dropdown with entity icons and selection states
- add blur-to-close functionality for scope dropdown
- support Multi Entity Lookup pattern with combobox-group layout
- maintain existing API compatibility for single-scope lookups
- replace manual slds-icon_container spans with container={true}
- unify data item icons to use Icon component container prop
- unify search icon to use Icon component container prop
- unify scope dropdown icon to use Icon component container prop
- simplify code by leveraging Icon component functionality
- ensure consistent Icon usage across all components
- add selected state combobox with SLDS-compliant markup structure
- implement entity icon and selected value display with slds-media layout
- add remove selection button with close icon and accessibility
- use slds-lookup__result-text for selected value display
- implement conditional rendering between selected and search states
- add onRemoveSelection handler for clearing selection
- maintain proper aria attributes for selected state combobox
- follow reference markup pattern for selected state display
- add iconAlign prop to control search icon position (left/right)
- implement dynamic className generation for icon positioning
- add slds-input-has-icon_left/right and slds-input__icon_left/right classes
- restore Stories functionality by uncommenting scope-related features
- restore iconAlign: 'left' in WithSearchIconInLeft story
- restore scopes: LOOKUP_SCOPES in MultiScope story
- restore scope event handlers in LookupControlled component
- complete all planned Lookup component features and improvements
@msmx-mnakagawa msmx-mnakagawa force-pushed the support-slds-2-lookup branch from 289545a to 296b514 Compare June 13, 2025 05:27
@msmx-mnakagawa msmx-mnakagawa changed the base branch from support-slds-2-form-element-field-set to support-slds-2 June 13, 2025 05:27
@msmx-mnakagawa msmx-mnakagawa marked this pull request as ready for review June 13, 2025 05:47
Copy link
Collaborator

@stomita stomita left a comment

Choose a reason for hiding this comment

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

Too small icon and maybe bigger down icon of scope dropdown button, comparing to the standard multi-scope lookup

CleanShot 2025-06-17 at 11 47 25@2x

Standard lookup field of multi scope:
CleanShot 2025-06-17 at 11 49 29@2x

Copy link
Collaborator

@stomita stomita left a comment

Choose a reason for hiding this comment

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

Scope dropdown of lookup should be keyboard navigatable (by up/down arrow, return key, esc key, and so on), like current dropdown button implementation.

@msmx-mnakagawa
Copy link
Collaborator Author

@stomita

Too small icon and maybe bigger down icon of scope dropdown button, comparing to the standard multi-scope lookup

I've tried to tweak the layout as below.
Could you confirm again...?
スクリーンショット 2025-06-19 10 25 31

@msmx-mnakagawa
Copy link
Collaborator Author

@stomita

Scope dropdown of lookup should be keyboard navigatable (by up/down arrow, return key, esc key, and so on), like current dropdown button implementation.

I've tried to add keyboard handlers, so could you take a look again...?

@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 19, 2025 01:30
</ul>
</div>
)}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Divide into sub components as the former implementation does, not having large JSX tree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I got it.
I've divided the parent one to sub components in 2b8cfec.

@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 19, 2025 05:51
@msmx-mnakagawa msmx-mnakagawa marked this pull request as draft June 19, 2025 06:09
@msmx-mnakagawa
Copy link
Collaborator Author

FYI, I've removed aria-labelledby in 5edc2d8, reflecting #472 (comment).

@msmx-mnakagawa msmx-mnakagawa marked this pull request as ready for review June 19, 2025 06:22
const onSelect = useEventCallback((entry: LookupEntry | null) => {
onSelect_?.(entry);
});
const renderListHeader = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to be a function, just assign to var like const listHeaderItem = !listHeader ? null : <li ... /> or simply inlining with root tree would be enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I fixed it in bf62197.

setScopeOpened(!scopeOpened);
}
},
isIgnoreTabNavigation: () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In terms of naming conventions, isTabNavigationIgnored or ignoreTabNavigation would be more grammatically appropriate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I changed the naming with isTabNavigationIgnored in 2078825.

setScopeFocusedIndex(-1);
} else {
const prevIndex = Math.max(scopeFocusedIndex - 1, 0);
setScopeFocusedIndex(prevIndex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This approach is setting react state and triggers re-render to Lookup component, which may or may not introduce some difficulties (especially regarding to the focus of elements). If you are going to keep the focus index in state, scoping the handler to a hook and capsulate it to the sub component that involves the focus would be preferable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I tried to restrict the scope of state changes in 3664759.
Does my understanding match with yours?

e.preventDefault();
e.stopPropagation();
onResetSelection?.();
const createKeyHandler = (config: KeyHandlerConfig) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic can be directly implemented using hook.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stomita
I reimplemented it as a hook in 4ef6024.

@msmx-mnakagawa msmx-mnakagawa force-pushed the support-slds-2-lookup branch from 626fa5c to 3664759 Compare June 20, 2025 02:08
@msmx-mnakagawa msmx-mnakagawa requested a review from stomita June 20, 2025 02:14
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.

2 participants