Skip to content

Conversation

@kraenhansen
Copy link
Contributor

@kraenhansen kraenhansen commented Nov 19, 2025

Description

This PR upgrades the non-modal and non-chat (although some updates to the chat packages were made) related LG packages to their latests version.

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@kraenhansen kraenhansen self-assigned this Nov 19, 2025
@kraenhansen kraenhansen added dependencies Pull requests that update a dependency file no release notes Fix or feature not for release notes labels Nov 19, 2025
@kraenhansen kraenhansen force-pushed the kh/leafygreen-non-modal-updates branch 3 times, most recently from 784e3c5 to f130e3d Compare November 19, 2025 14:07
@kraenhansen kraenhansen marked this pull request as ready for review November 19, 2025 16:15
@kraenhansen kraenhansen requested a review from a team as a code owner November 19, 2025 16:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR upgrades non-modal LeafyGreen UI components across the Compass codebase. The upgrade addresses type incompatibilities, removes deprecated props, updates test selectors to match new component structures, and removes a workaround patch script that is no longer needed.

Key changes:

  • Upgrades LeafyGreen component versions in package.json files
  • Adds type parameters and as props to Button and IconButton components for polymorphic type support
  • Updates test selectors to match new LeafyGreen component test IDs and ARIA attributes
  • Removes deprecated props like readOnly and adds new type exports

Reviewed Changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/compass-components/package.json Updates LeafyGreen package versions and removes postinstall script
package.json Updates root-level LeafyGreen dependencies to match component upgrades
packages/compass-components/src/components/leafygreen.tsx Updates imports to use named exports and removes TextInput wrapper workaround
packages/compass-components/src/components/links/link.tsx Adds polymorphic type support to Button and IconButton components
packages/compass-components/src/hooks/use-error-details.tsx Removes ts-expect-error comment for autoFocus prop
packages/compass-components/scripts/patch-leafygreen-button.js Removes obsolete patch script for LeafyGreen button package
packages/compass-editor/src/editor.tsx Adds autoFocus prop support to editor component
packages/compass-e2e-tests/helpers/selectors.ts Updates test selectors for new LeafyGreen modal close button ID
packages/compass-e2e-tests/helpers/commands/*.ts Updates E2E test commands to use clickVisible instead of keyboard events
packages/compass-crud/src/components/*.tsx Removes deprecated readOnly prop and adds data-testid attributes
Other component files Adds as="button" props and updates ref types for polymorphic components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (autoFocusRef.current) {
editorViewRef.current?.focus();
}
}, [autoFocusRef]);
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

The useLayoutEffect dependency array includes autoFocusRef, but refs don't trigger re-renders. Since autoFocus is passed as a prop and stored in a ref that never changes, this effect should either have an empty dependency array [] or be removed in favor of a simpler approach. The current implementation will only run once anyway, but the dependency is misleading.

Suggested change
}, [autoFocusRef]);
}, []);

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gribnoysup what do you think of this? I vaguely remember talking with you about this at the offsite.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You indeed don't need to provide refs in the dependencies, react-hooks eslint rule also accounts for this (I'm assuming react compiler would do the same). Is it confusing? I don't think it is, but is it somewhat unnecessary. I've no idea what the bot means by simpler approach

ref: React.ForwardedRef<HTMLButtonElement>
) => {
const { utmSource, utmMedium } = useRequiredURLSearchParams();
const { href } = rest as { href?: string };
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

Using type assertion as { href?: string } bypasses TypeScript's type checking. Consider extracting href from rest using destructuring with a type guard or conditional type checking instead of type assertion to maintain type safety.

Copilot uses AI. Check for mistakes.
ref: React.ForwardedRef<HTMLButtonElement>
) => {
const { utmSource, utmMedium } = useRequiredURLSearchParams();
const { href } = rest as { href?: string };
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

Using type assertion as { href?: string } bypasses TypeScript's type checking. Consider extracting href from rest using destructuring with a type guard or conditional type checking instead of type assertion to maintain type safety.

Copilot uses AI. Check for mistakes.
});
execFile(
path,
args,
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

The addition of encoding: 'utf8' changes the function's behavior but lacks explanation. Add a comment explaining why this encoding is now explicitly required for the LeafyGreen upgrade or what issue it addresses.

Suggested change
args,
args,
// Explicitly set encoding to 'utf8' to ensure stdout/stderr are returned as strings.
// This is required for compatibility with the LeafyGreen upgrade, which expects string output.

Copilot uses AI. Check for mistakes.
Comment on lines 262 to 264
expect(
await browser.$(Selectors.AssistantChatMessages).isDisplayed()
).equals(false);
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

Use .to.equal(false) instead of .equals(false) for consistency with Chai assertion style used elsewhere in the test file. The current syntax uses the wrong assertion method.

Copilot uses AI. Check for mistakes.
expect(await getDisplayedMessages(browser)).to.deep.equal([]);
expect(
await browser.$(Selectors.AssistantChatMessages).isDisplayed()
).equals(false);
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

Use .to.equal(false) instead of .equals(false) for consistency with Chai assertion style used elsewhere in the test file. The current syntax uses the wrong assertion method.

Suggested change
).equals(false);
).to.equal(false);

Copilot uses AI. Check for mistakes.
package.json Outdated
"@leafygreen-ui/text-area": "^12.1.2",
"@leafygreen-ui/card": "^13.2.0",
"@leafygreen-ui/logo": "^11.1.0",
"@leafygreen-ui/tabs": "^17.0.6",
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

The addition of the nwsapi dependency lacks context. Add a comment or update the PR description explaining why this specific package is needed for the LeafyGreen upgrade.

Suggested change
"@leafygreen-ui/tabs": "^17.0.6",
"@leafygreen-ui/tabs": "^17.0.6",
// The 'nwsapi' dependency is required for compatibility with upgraded LeafyGreen UI components.

Copilot uses AI. Check for mistakes.
@kraenhansen kraenhansen requested review from gribnoysup and lerouxb and removed request for ivandevp November 20, 2025 06:53
Comment on lines +178 to +184

// Close the drawer if open to provide a clean environment for the next test
const drawerCloseButton = browser.$(Selectors.AssistantDrawerCloseButton);
if (await drawerCloseButton.isDisplayed()) {
await browser.clickVisible(drawerCloseButton);
await drawerCloseButton.waitForDisplayed({ reverse: true });
}
Copy link
Contributor Author

@kraenhansen kraenhansen Nov 20, 2025

Choose a reason for hiding this comment

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

I'm suggesting closing the drawer (if open) to provide a clean environment between tests.

@kraenhansen kraenhansen force-pushed the kh/leafygreen-non-modal-updates branch from f130e3d to b1946f0 Compare November 20, 2025 10:29
package.json Outdated
"@leafygreen-ui/card": "^13.2.0",
"@leafygreen-ui/logo": "^11.1.0",
"@leafygreen-ui/tabs": "^17.0.6",
"nwsapi": "2.2.12"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you explain what's the context here? I don't see it in any leafygreen transitive deps, in our current package-lock it's on the same version as you locked here as far as I can see. Specifically that we're fixing it to the exact number looks peculiar to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a dependency of jsdom and we were hitting issues with nwsapi@2.2.22 (released only 2 months ago) not being able to parse testid attributes with colons in them.

  1) In-Use Encryption
       supports multiple kms providers from same type
         allows rename of KMS provider:
     SyntaxError: 'input#local,,,A1.lg-ui-form-field-input-0000 button.lg-ui-form-field-icon-0000' is not a valid selector

I suspect I was seeing this because I nuked the package lock at some point during this process, which caused the new version of nwsapi to get pulled in (we're on jsdom@24.1.3 which has nwsapi@^2.2.12).

I'll try to remove this override to see if the regression re-appears 🤔 In any case, it's just a package-lock rebuild away from triggering again - so it might be good to get in as a separate PR anyway ...

Copy link
Collaborator

@gribnoysup gribnoysup Nov 21, 2025

Choose a reason for hiding this comment

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

Got it, no wonder I see so many changes in package-lock that are not related to leafygreen-ui! Let's open a ticket to address this: I guess it can be something like "bump jsdom to latest" so that we don't focus only on transitive dep there?

On a related note, I mentioned this before, but I will do it again just to make sure we're on the same page here:

it's just a package-lock rebuild away from triggering again

This should be a "there's no way around this" kind-of situation (I don't doubt this PR might be one of those rare cases), I think it would be very much worth calling out in the PR description when this happens. Lockfiles are there to make sure that we are not inroducing unexpected version changes in our dependency tree. Changes that big can't even be reviewed via GH UI meaning they always require very special attention.

"@leafygreen-ui/tokens": "^4.0.0",
"@leafygreen-ui/tooltip": "^14.2.2",
"@leafygreen-ui/typography": "^22.2.0",
"@lg-chat/avatar": "^7.0.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are those not "non-modal" components? Looks like latest is 8, not 7. Same question for some other lg-chat stuff, curious why we're not updating those too

Copy link
Contributor Author

@kraenhansen kraenhansen Nov 20, 2025

Choose a reason for hiding this comment

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

You're right - good call-out.

Short answer is I believe these new versions were released since I branched off and I didn't want to complicate things by upgrading these in the process as well. I imagine I'll need to circle back on these once my modal upgrading PR lands 🙄

Copy link
Contributor Author

@kraenhansen kraenhansen Nov 20, 2025

Choose a reason for hiding this comment

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

BTW - some of these also got renamed from the @lg-chat to @leafygreen-ui.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, got it, makes sense, keeping them out sounds okay to me, just wanted to make sure we didn't just accidentally missed them here 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed the PR title to reflect this.

@kraenhansen kraenhansen changed the title chore(components): upgrade LeafyGreen non-modal components COMPASS-9642 chore(components): upgrade LeafyGreen non-modal & non-chat components COMPASS-9642 Nov 20, 2025
@kraenhansen kraenhansen force-pushed the kh/leafygreen-non-modal-updates branch from 0ad7378 to 1cd5f7c Compare November 21, 2025 07:28
Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

As far as I can tell looking through the package-lock and relying on our e2e-s and running the build locally to confirm that the app is still functioning I think it's LGTM (there's some unexpected unhoisting happening, but that's not the end of the world), but as we changed almost every dependency in our dependency tree (both prod and dev) and there's no way to say exactly what might've changed there I think merging this PR should be followed by doing a Beta release to make sure all release pipelines and resulting app is still working as expected.

Once again want to mention that nuking package-lock is a "break glass" kind of operation. As this patch doing most of the updating it seems, I hope going forward this approach can be avoided.

@kraenhansen
Copy link
Contributor Author

merging this PR should be followed by doing a Beta release to make sure all release pipelines and resulting app is still working as expected.

I'd like to merge and include the other PRs upgrading LG components in that beta release as well - would that work for you?

nuking package-lock is a "break glass" kind of operation.

To be clear, I believe I did this during the process, resulting in some of the changes I'm proposing. I don't however believe that reflects the current state of this PR - the commits upgrading LG components was not the result of deleting and recreating the package-lock entirely.

@gribnoysup
Copy link
Collaborator

I'm not sure I follow, sorry 🙂 There are a lot of changes in package-lock related to our app build dependencies (various transitive deps of various electron packaging libraries, webpack and some plugins / loaders for example), they wouldn't get bumped with leafygreen update, so there are way more changes in this patch than just related to leafygreen

@kraenhansen kraenhansen force-pushed the kh/leafygreen-non-modal-updates branch from 1cd5f7c to c4ed186 Compare November 24, 2025 15:41
@kraenhansen kraenhansen changed the title chore(components): upgrade LeafyGreen non-modal & non-chat components COMPASS-9642 chore(components): upgrade LeafyGreen non-modal components COMPASS-9642 Nov 24, 2025
@kraenhansen
Copy link
Contributor Author

kraenhansen commented Nov 24, 2025

I rebased (as the package-lock got a conflict) and included #7589 and 7590 into this PR (as the changes needed to tests and code was minimal).

@kraenhansen kraenhansen force-pushed the kh/leafygreen-non-modal-updates branch 2 times, most recently from 66ec1e3 to 8b483ab Compare November 24, 2025 16:10
This was fixed in LG-5063
@kraenhansen kraenhansen force-pushed the kh/leafygreen-non-modal-updates branch from 7b62353 to 694ac4e Compare November 25, 2025 14:15
@kraenhansen kraenhansen merged commit b3d22cc into main Nov 25, 2025
61 checks passed
@kraenhansen kraenhansen deleted the kh/leafygreen-non-modal-updates branch November 25, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file no release notes Fix or feature not for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants