-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(SingleEntitySelectMenuItems): extract Add New
button from entitiesToSelect
#8474
fix(SingleEntitySelectMenuItems): extract Add New
button from entitiesToSelect
#8474
Conversation
…iesToSelect - and add it as a separate element - to be consistent with `MultiRecordSelect`
Remaining work:
|
…sContainer /> for padding
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.
PR Summary
This PR extracts the "Add New" button from entity selection lists and places it in its own container for consistent dropdown menu behavior across the application.
- Removed
onCreate
prop and "Add New" button logic fromSingleEntitySelectMenuItems.tsx
to simplify entity list rendering - Added dedicated
CreateNewButton
container inSingleEntitySelectMenuItemsWithSearch.tsx
with proper separators - Standardized dropdown menu behavior by ensuring "Add New" button appears in its own section below entity list
- Fixed duplicate "Add New" button issue present in previous PR fixes: Standardize "Add New" button in dropdown menus #8169 #8353
2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
...y-front/src/modules/object-record/relation-picker/components/SingleEntitySelectMenuItems.tsx
Outdated
Show resolved
Hide resolved
...c/modules/object-record/relation-picker/components/SingleEntitySelectMenuItemsWithSearch.tsx
Outdated
Show resolved
Hide resolved
...c/modules/object-record/relation-picker/components/SingleEntitySelectMenuItemsWithSearch.tsx
Outdated
Show resolved
Hide resolved
...c/modules/object-record/relation-picker/components/SingleEntitySelectMenuItemsWithSearch.tsx
Show resolved
Hide resolved
…e of an "*end" positioned `dropdownPlacement` - display is inverted when the `Placement` is at the `end`, following the `MultiRecordSelect` component design - add a story to display the `end` placement - pass down the `dropdownPlacement` prop in `SingleEntitySelect`
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 passed down a prop in SingleEntitySelect
. Don't know if it was a good idea, I can remove it if needed.
@@ -15,6 +15,7 @@ export type SingleEntitySelectProps = { | |||
|
|||
export const SingleEntitySelect = ({ | |||
disableBackgroundBlur = false, | |||
dropdownPlacement, |
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 took the liberty of adding this prop and passing it down to SingleEntitySelectMenuItemsWithSearch
. I don't know if it's a good idea:
- it does expand
SingleEntitySelect
contract... which I recon can be less maintainable. - however the
dropdownPlacement
is already a prop available inSingleEntitySelect
type interface; it just wasn't passed down to the underlying component, which I found was weird - it allows testing and using this prop in Storybook
Let me know what you think.
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.
Yes makes sense to pass it if the below component has it I agree!
export const WithEndPlacement: Story = { | ||
args: { dropdownPlacement: 'bottom-end' }, | ||
}; |
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 added a story to check the select with an end placement
This looks great thanks a lot! This introduced a small bug I think, I haven't dug into it yet |
Actually I think there's a misunderstanding on what placement is supposed to be. This was a hack to maintain a stable place input. So the text input always remained in the same position, and the results were displayed either below or after the input depending on the space available. |
Thanks for your explanation, I would never have that figured out. I'm gonna try to dig a little deeper, just out of curiosity, to understand why the dropdown is out there floating. I'm gonna try to run the Once that's done, I'll remove exposing the |
@nicolasrouanne thanks a lot! Let us know if it's too much word and you want us to take over |
…`SingleEntitySelect` - and passing it down to `SingleEntitySelectMenuItemsWithSearch` - since it broke the position of the dropdown, see twentyhq#8474 (comment)
I reverted exposing the I tried to reproduce the bug using E2E tests, FWIW I didn't really managed to get E2E tests running in my local environment. Here's what I did: cp ./packages/twenty-e2e-testing/.env.example ./packages/twenty-e2e-testing/.env # setup E2E env variables
npx nx test:e2e:setup twenty-e2e-testing # install playwright
npx nx database:reset twenty-server # reset dev database to start with a clean slate
npx nx start # start local dev server
npx nx test:e2e:ui twenty-e2e-testing # run using --ui to see playwright ui and browser Tests failed in login and all subsequent tests using a login-like behaviour since I never get the "Continue with email" button, I always have the It's probably an environment misconfiguration, I stopped investigating for now. Note I feel that the developer guide would benefit from an explanation on how to run E2E tests |
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.
Great work! Thanks a lot. I didn't realize this would be so complex to fix everything, there are still a few glitches unrelated to the initial ask which we'll fix in another PR.
Agree with E2E tests, it's such a pain that I've never ran them locally I just wait for the CI
Thanks @nicolasrouanne for your contribution! |
|
||
let onCreateWithInput = undefined; | ||
|
||
if (isDefined(onCreate)) { |
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.
FYI I think we should have kept that #8529 (comment)
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.
Sorry to have introduced that 😢
I think I didn't really understand what it was used for.
I was under the impression my change didn't impact the public API of the component... but it seems I was wrong, sorry.
It's weird that TS didn't catch 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.
No problem at al! I should have seen it 😅 (+ lack of good tests on our codebase). That code looks ugly I would have been tempted to remove it too!
Description
Closes #8169
Extract Add New button from entitiesToSelect and add it as a separate element .
There doesn't seem to be a point in having Add New as part of a list, it seems better off in its own component, apart from list items
Rationale
There already is #8353 addressing the same issue, but it seems it doesn't really remove the duplicate "Add New" in the list, leaving a duplicate "Add New" in
SingleEntitySelect