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: Added floating-ui hook usage for ComboBox #16585

Merged
merged 11 commits into from
Jun 11, 2024

Conversation

Gururajj77
Copy link
Contributor

Closes #16470

Added floating-ui for combobox

Changelog

New

  • Imported useFloating hook from floating-ui library.
  • added new experimental prop, autoAlign which toggles the use of the useFloating hook.
  • a new useEffect hook to apply styles to the Combobox using CSSOM

Changed

  • added ref.setReference to ListBox and ref.setFloating to ListBox.Menu

Testing / Reviewing

Check the new Experimental Auto Align story from the Combobox component.

@Gururajj77 Gururajj77 requested a review from a team as a code owner May 28, 2024 10:15
Copy link

netlify bot commented May 28, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ff09fdc
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/66685cde9465200008a8270f
😎 Deploy Preview https://deploy-preview-16585--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 28, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit ff09fdc
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/66685cdeb419640008daca36
😎 Deploy Preview https://deploy-preview-16585--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Gururajj77 Gururajj77 changed the title Combobox fui 2 feat May 28, 2024
@Gururajj77 Gururajj77 changed the title feat feat: Added floating-ui library usage for ComboBox May 28, 2024
Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

Do we really need an auto align prop in this case ? Since its a comboBox, auto align should not be an optional behavior like popover. Auto align should be a default behaviour and should not be changed in conbobox.So implementation of floating UI in this case should not be optional( i.e should not depend on auto align prop)

@tay1orjones What do you think on this ?

@Gururajj77
Copy link
Contributor Author

Do we really need an auto align prop in this case ? Since its a comboBox, auto align should not be an optional behavior like popover. Auto align should be a default behaviour and should not be changed in combobox. So implementation of floating UI in this case should not be optional( i.e should not depend on auto align prop)

@tay1orjones What do you think on this ?

We can definitely do this if it's not considered a breaking change

@guidari
Copy link
Contributor

guidari commented May 29, 2024

Do we really need an auto align prop in this case ? Since its a comboBox, auto align should not be an optional behavior like popover. Auto align should be a default behaviour and should not be changed in conbobox.So implementation of floating UI in this case should not be optional( i.e should not depend on auto align prop)

Yeah, I agree with Riddhi on this! It is the same approach I'm having on MultiSelect and FilterableMultiselect, I'm just making the Floating UI alignment as default.

@Gururajj77 Gururajj77 changed the title feat: Added floating-ui library usage for ComboBox feat: Added floating-ui hook usage for ComboBox Jun 3, 2024
@Gururajj77 Gururajj77 requested a review from a team as a code owner June 5, 2024 10:29
@@ -105,3 +106,5 @@ export const generateItems = (amount, generator) =>
.map((_, i) => generator(i));

export const customItemToString = ({ field }) => field;

export const waitForPosition = () => act(async () => {}); // Flush microtasks. Position state is ready by this line.
Copy link
Member

Choose a reason for hiding this comment

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

Just want to make a note that this comes from https://floating-ui.com/docs/react#testing and more context is here: floating-ui/react-popper#368 (comment)

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Looks so good 🔥 just a couple minor things

packages/react/src/components/ComboBox/ComboBox.tsx Outdated Show resolved Hide resolved
packages/react/src/components/ComboBox/ComboBox.tsx Outdated Show resolved Hide resolved
packages/react/src/components/ComboBox/ComboBox.tsx Outdated Show resolved Hide resolved
Gururajj77 and others added 4 commits June 6, 2024 19:13
update comments for interface

Co-authored-by: Taylor Jones <[email protected]>
update comment for prop-types

Co-authored-by: Taylor Jones <[email protected]>
removing `fallbackAxisSideDirection` and keeping it flip()

Co-authored-by: Taylor Jones <[email protected]>
adding placement as we already have direction prop coming in

Co-authored-by: Taylor Jones <[email protected]>
@riddhybansal
Copy link
Contributor

Do we really need an auto align prop in this case ? Since its a comboBox, auto align should not be an optional behavior like popover. Auto align should be a default behaviour and should not be changed in conbobox.So implementation of floating UI in this case should not be optional( i.e should not depend on auto align prop)

@tay1orjones What do you think on this ?

This is discussed on slack

@riddhybansal
Copy link
Contributor

LGTM !! Just need to run yarn format !!

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

There were some weird unrelated changes highlighted in percy - might just be due to being out of date from latest with main. I just pushed the button to update, if status checks pass I think this LGTM 🎉

Copy link
Member

@alisonjoseph alisonjoseph left a comment

Choose a reason for hiding this comment

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

LGTM 🔥

Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

LGTM

@alisonjoseph alisonjoseph added this pull request to the merge queue Jun 11, 2024
Merged via the queue into carbon-design-system:main with commit cb30e67 Jun 11, 2024
22 checks passed
@Gururajj77 Gururajj77 deleted the combobox-fui-2 branch June 18, 2024 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add floating-ui to @carbon/react ComboBox
5 participants