-
Notifications
You must be signed in to change notification settings - Fork 193
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(connections-navigation): connect in new window via connect split-button COMPASS-8473 #6577
base: main
Are you sure you want to change the base?
Conversation
@@ -63,6 +63,7 @@ | |||
"@leafygreen-ui/search-input": "^4.0.0", | |||
"@leafygreen-ui/segmented-control": "^9.0.0", | |||
"@leafygreen-ui/select": "^13.0.0", | |||
"@leafygreen-ui/split-button": "../../../leafygreen-ui/packages/split-button/leafygreen-ui-split-button-v3.0.0.tgz", |
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.
This is a temporary workaround and needs to be updated once my proposed changes merge and release.
9bbdf1c
to
1dcbbfb
Compare
@@ -39,7 +33,7 @@ export type ItemActionControlsProps<Action extends string> = { | |||
'data-testid'?: string; | |||
}; | |||
|
|||
export function ItemActionControls<Action extends string>({ | |||
export function ItemActionControls<Action extends string = string>({ |
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.
TIL that you can have a default
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.
Yeah – it usually just reduces type safety, though, because then consumers are likely to omit the type (and the default is typically the most generic type available).
This also seems to be one of those cases where type safety goes away – I don't seen an obvious reason for that in the rest of the code, though, so maybe in this particular case we could reconsider?
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.
🙂 TBH, it's likely not strictly needed here, since we'll always be using this in a way that can infer the type of this type parameter from the props
.
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.
That being said - those changes are actually a part of #6560 (which needs to be reviewed and merged first).
c432c5a
to
cffbfbb
Compare
cffbfbb
to
ddc2f45
Compare
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.
Overall looks good, would be nice to try to run this locally after leafygreen patch is released
@@ -282,6 +282,8 @@ export const Single = { | |||
export const Multiple = { | |||
ConnectionsTitle: '[data-testid="connections-header"]', | |||
ConnectButton: '[data-action="connection-connect"]', | |||
ConnectInNewWindowButton: '[data-action="connection-connect-in-new-window"]', | |||
ConnectDropdownButton: '[aria-label="see more connection options"]', |
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.
Doesn't look like a great selector, anything better we can target here?
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.
What in particular don't you like about this? That it will break if the button label gets updated?
This is targeting a "trigger" button within the SplitButton
, but most props are forwarded to the "left most" button: https://github.com/mongodb/leafygreen-ui/blob/main/packages/split-button/src/SplitButton/SplitButton.tsx#L88
This is the trigger I'm targeting 🤔
<button
data-lgid="lg-button"
type="button"
class="lg-ui-button-0000 leafygreen-ui-lt73jo"
aria-disabled="false"
aria-label="see more connection options"
aria-controls="lg-split-button-menu-56"
aria-expanded="true"
aria-haspopup="true">
...
</button>
Alternatively I can select this relative to its sibling:
[data-testid="sidebar-navigation-item-actions-connection-connect-action"] + button
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.
I don't like a brittle selector that targets specifically an aria-label attribute, if leafygreen team changes how they apply a label (for example switching to visually hidden element or using labelledby instead of label directly) this will break. If you want to select by inferred button label, you should use selectors designed for that, either a button=<text>
or aria/<text>
selectors. You can learn more about wdio selectors in the documentation
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.
We also usually use testid selectors in e2e tests, which are also mentioned as recommented by the documentation, so if we can pass a testid here, that's also an option and consistent with most of the other selectors. If we can't, it might be worth asking leafygreen team to add the option to pass it
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.
I've made a PR for LG adding a constant data-testid
attribute to the trigger element: mongodb/leafygreen-ui#2621
Related, I noticed that LG was also selecting the trigger in their test, relative to the other button: https://github.com/mongodb/leafygreen-ui/blob/f5d842764faf5b498f799d1710288ca964a93141/packages/split-button/src/SplitButton/SplitButton.spec.tsx#L52
Description
Merging this PR will:
SplitButton
with a dropdown menu, containing options to "Connect Here" and "Connect in a New Window".ItemActionControls
being "hideable" (through thesetHideable
callback) allowing children (theConnectButton
in particular) to prevent the controls from being hidden once the cursor leaves the connection row. I use this to prevent controls (henceSplitButton
and it'sMenu
) to be removed from the tree as the cursor is moved out of theConnectButton
, across and into the menu: If the menu is opened, the controls stay visible.connect-in-new-window-1.mov
TODOs
ItemActionControls
#2 #6560 merge.SplitButton
component once we're able to passrenderDarkMenu
LG-4721: FixSplitButton
's menu is rendered in dark-mode regardless of value passed throughrenderDarkMenu
mongodb/leafygreen-ui#2601 and to get LG-4714: Fix usingSplitButton
as a managed component mongodb/leafygreen-ui#2596. I'm currently using a local install of the@leafygreen-ui/split-button
.Checklist
Motivation and Context
Open Questions
Dependents
SplitButton
as a managed component mongodb/leafygreen-ui#2596SplitButton
's menu is rendered in dark-mode regardless of value passed throughrenderDarkMenu
mongodb/leafygreen-ui#2601ItemActionControls
#2 #6560Types of changes