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

Spike: Bring the DS Single and Multiselect into Storybook #197

Closed
natalia-fitzgerald opened this issue Oct 6, 2023 · 6 comments · Fixed by #206
Closed

Spike: Bring the DS Single and Multiselect into Storybook #197

natalia-fitzgerald opened this issue Oct 6, 2023 · 6 comments · Fixed by #206
Assignees
Labels

Comments

@natalia-fitzgerald
Copy link

natalia-fitzgerald commented Oct 6, 2023

Explore implementing DSR Select components by matching the Design System's HTML layout instead of attempting to replicate the styling using the react-select library.

Variants

We want to understand

  • What are the Pros / Cons of using primarily HTML instead of the React library?
  • Any blockers?
@natalia-fitzgerald natalia-fitzgerald changed the title Spike: Bring the DS Single and Multiselect in Storybook Spike: Bring the DS Single and Multiselect into Storybook Oct 6, 2023
@shindigira shindigira assigned shindigira and unassigned shindigira Oct 11, 2023
@meissadia meissadia self-assigned this Oct 12, 2023
@meissadia
Copy link
Contributor

meissadia commented Oct 18, 2023

Single select

I've been able to integrate the Single select successfully.

Multiselect

The DS multiselect is a highly customized version of the HTML select and has been more difficult but we're close.

Issues in progress

  • How can we access the internal state of which items are selected?
    • The internal DS select state is not accessible
    • I've implemented a workaround for tracking selected items in the React wrapper's state, which seems to be working well
      • Cons: It's a very hacky workaround and I would still need to implement keyboard accessibility
      • Pros: It gets us one step close to using the DS Multiselect
  • How can we get the icons in the selected Pills to display correctly?
    • Icon gets rendered as a path string instead of the SVG (option 4)
    • I've been able to get as far as stripping out that string but not able to get the actual icon to render (option 2, 3)
    • Screenshot 2023-10-18 at 2 35 46 PM
    • Potential workaround: Render the pills ourselves, similar to what we were doing with the react-select version of the Dropdown
      • Pros: We still use most of the DS multiselect logic and styles
      • Cons:
        • May need to reimplement accessibility (thought I think that was already addressed)
        • Would need to hide DS multiselect's rendered pills
        • Would need to render our own pills using the same classnames to be able to reuse DS styles

Pending functionality/issues/questions

  • [Single] Support a default selected option?
  • [Single] Support placeholder text?
  • [Multi] Support default selected options?
  • [Multi] Can we adjust the number of selections allowed (currently 5)?
  • [Multi] Can we adjust the placeholder text?
  • [Multi] Is there a way to tie into the mouse/keyboard events? I see the addEventListener function but added event handlers don't seem to be triggered upon Multiselect interaction.

@meissadia
Copy link
Contributor

meissadia commented Oct 31, 2023

Next steps in DS:

  • Explore splitting Tag rendering into separate component from Multiselect
  • Explore exposing the Multiselect model for easier integration

Update:

@meissadia
Copy link
Contributor

meissadia commented Nov 7, 2023

Status as of 11/7:

Last Pending issue from above:

  • [Multi] Support default selected options?

@meissadia
Copy link
Contributor

  • Tried adding a jest.config.js to apply 'jest-svg-transformer'

FAIL src/components/Select/Select.test.tsx [ src/components/Select/Select.test.tsx ]
FAIL src/components/TextIntroduction/TextIntroduction.test.tsx [src/components/TextIntroduction/TextIntroduction.test.tsx ]
FAIL src/components/Link/Link.test.tsx [ src/components/Link/Link.test.tsx ]
FAIL src/components/Well/Well.test.tsx [ src/components/Well/Well.test.tsx ]
FAIL src/components/Alert/Alert.test.tsx [ src/components/Alert/Alert.test.tsx ]
FAIL src/components/TextInput/TextInput.test.tsx [ src/components/TextInput/TextInput.test.tsx ]
FAIL src/components/Table/Table.test.tsx [ src/components/Table/Table.test.tsx ]

@meissadia
Copy link
Contributor

@meissadia
Copy link
Contributor

Interesting point of note: The following fixes the issue of DS icons not rendering in Vite!!! I don't know the wider implications of using this approach, but it does allow DS rendered icons to show up correctly in DSR.

In vite.config.ts

svgLoader({
  defaultImport: 'raw'
}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants