-
Notifications
You must be signed in to change notification settings - Fork 38
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
Enabling hide
middleware in DropdownMenu
by default
#2233
base: main
Are you sure you want to change the base?
Conversation
hide
middleware in DropdownMenu
middleware.hide
prop in DropdownMenu
middleware.hide
prop in DropdownMenu
hide
middleware in DropdownMenu
by default
* @see https://floating-ui.com/docs/middleware | ||
*/ | ||
middleware?: { | ||
hide?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building upon #2233 (comment), I think middleware.hide
should be exposed in all places that use usePopover
(directly or indirectly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposed middleware.hide
in DropdownMenu
, ComboBox
. Exposed popoverOptions.middleware.hide
in custom Select
(https://github.com/iTwin/iTwinUI/pull/2233/files/68bcf9f57d921713dffb83cee347a0e0d1afe313..0d2b8426dac7565686127edb819d4e7e153181bc#diff-81cc6906121a5abe5bd05042dc29b66dcd2eb7dfdd771cffeb61c7387420652f).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be under dropdownMenuProps
in ComboBox
and under popoverProps
in Select
.
Co-authored-by: Mayank <9084735+mayank99@users.noreply.github.com>
} from '@itwin/itwinui-react'; | ||
import { useSearchParams } from '@remix-run/react'; | ||
import { SvgMore } from 'node_modules/@itwin/itwinui-react/esm/utils/index.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not rely on these internal paths; instead import from @itwin/itwinui-icons-react
if you need this icon.
@@ -3,7 +3,7 @@ | |||
* See LICENSE.md in the project root for license terms and full copyright notice. | |||
*--------------------------------------------------------------------------------------------*/ | |||
import * as React from 'react'; | |||
import { render } from '@testing-library/react'; | |||
import { render, waitFor } from '@testing-library/react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is waitFor
being used in this unit test? I think it might be a stray import.
Changes
Fixes #2235.
This PR makes
DropdownMenu
expose themiddleware
prop. Thehide
middleware is enabled by default and can be opted out from. (#2233 (comment)).Only the
hide
middleware is modifiable for now. This keeps the API surface small, manageable, and less buggy. As and when we need to expose more middleware, we can do so in the future.Unrelated fixes:
hide
middleware inPopover
to actually applyvisibility: hidden
. Up till now, that middleware used to unintentionally be no-op. (sandbox)Popover
.foobar
by default. Doing{foo: true, ...userProps}
actually results in{foobar: undefined}
ifuserProps.foobar = undefined
. The fix I used was{foobar: userProps.foobar ?? true}
.Testing
Added e2e test and story.
@mayank99 pointed out some issues that we faced with the
hide
modifier in old versions of itwinui-react that used to use popper instead of floating-ui. I made sure that the previous issues no longer happen after this PR or are no longer related to this PR:hide
modifier from popper iTwinUI-react#783: I'm not sure what was the issue here. But iiuc, I don't think it relates to this PR since the trigger of a dropdown menu is usually a button that doesn't getwidth: 0; height: 0;
ordisplay: none;
.hide
modifier inComboBox
'susePopover()
call still does not give the problem demoed in the issue.Docs
Added changesets and docs.