-
Notifications
You must be signed in to change notification settings - Fork 245
chore(components): upgrade LeafyGreen non-modal (+ some chat related) components COMPASS-9642 #7582
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
Conversation
784e3c5 to
f130e3d
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.
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
asprops 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
readOnlyand 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]); |
Copilot
AI
Nov 19, 2025
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.
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.
| }, [autoFocusRef]); | |
| }, []); |
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.
@gribnoysup what do you think of this? I vaguely remember talking with you about this at the offsite.
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.
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 }; |
Copilot
AI
Nov 19, 2025
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.
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.
| ref: React.ForwardedRef<HTMLButtonElement> | ||
| ) => { | ||
| const { utmSource, utmMedium } = useRequiredURLSearchParams(); | ||
| const { href } = rest as { href?: string }; |
Copilot
AI
Nov 19, 2025
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.
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.
| }); | ||
| execFile( | ||
| path, | ||
| args, |
Copilot
AI
Nov 19, 2025
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.
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.
| 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. |
| expect( | ||
| await browser.$(Selectors.AssistantChatMessages).isDisplayed() | ||
| ).equals(false); |
Copilot
AI
Nov 19, 2025
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.
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.
| expect(await getDisplayedMessages(browser)).to.deep.equal([]); | ||
| expect( | ||
| await browser.$(Selectors.AssistantChatMessages).isDisplayed() | ||
| ).equals(false); |
Copilot
AI
Nov 19, 2025
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.
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.
| ).equals(false); | |
| ).to.equal(false); |
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", |
Copilot
AI
Nov 19, 2025
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.
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.
| "@leafygreen-ui/tabs": "^17.0.6", | |
| "@leafygreen-ui/tabs": "^17.0.6", | |
| // The 'nwsapi' dependency is required for compatibility with upgraded LeafyGreen UI components. |
|
|
||
| // 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 }); | ||
| } |
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'm suggesting closing the drawer (if open) to provide a clean environment between tests.
f130e3d to
b1946f0
Compare
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" |
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.
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
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 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 ...
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.
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", |
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.
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
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.
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 🙄
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.
BTW - some of these also got renamed from the @lg-chat to @leafygreen-ui.
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.
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 👍
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 renamed the PR title to reflect this.
0ad7378 to
1cd5f7c
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.
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.
I'd like to merge and include the other PRs upgrading LG components in that beta release as well - would that work for you?
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. |
|
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 |
1cd5f7c to
c4ed186
Compare
|
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). |
66ec1e3 to
8b483ab
Compare
This was fixed in LG-5063
…hen selecting aggregation stage operator
…les with BOM" test
7b62353 to
694ac4e
Compare
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
Motivation and Context
Open Questions
Dependents
Types of changes