Refactor MultipleObjectsPicker component (#10552)

Refactor to only have MultipleRecordPicker and SingleRecordPicker

What's done:
- SingleRecordPicker, MultipleRecordPicker
- RelationToOneInput
- RelationFromManyInput
- usage in TableCell, InlineCell, RelationDetailSection, Workflow

What's left:
- Make a pass on the app, to make sure the hotkeyScopes, clickOutside
are properly set
- Fix flashing on ActivityTarget
- add more tests on the code
This commit is contained in:
Charles Bochet
2025-03-10 15:04:09 +01:00
committed by GitHub
parent 7eabcc8774
commit f0de6d31b7
126 changed files with 2465 additions and 2242 deletions

View File

@ -3,10 +3,8 @@ import { DropdownOnToggleEffect } from '@/ui/layout/dropdown/components/Dropdown
import { DropdownComponentInstanceContext } from '@/ui/layout/dropdown/contexts/DropdownComponeInstanceContext';
import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';
import { dropdownHotkeyComponentState } from '@/ui/layout/dropdown/states/dropdownHotkeyComponentState';
import { dropdownMaxHeightComponentStateV2 } from '@/ui/layout/dropdown/states/dropdownMaxHeightComponentStateV2';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import styled from '@emotion/styled';
import {
Placement,
@ -68,11 +66,6 @@ export const Dropdown = ({
}: DropdownProps) => {
const { isDropdownOpen, toggleDropdown } = useDropdown(dropdownId);
const setDropdownMaxHeight = useSetRecoilComponentStateV2(
dropdownMaxHeightComponentStateV2,
dropdownId,
);
const isUsingOffset =
isDefined(dropdownOffset?.x) || isDefined(dropdownOffset?.y);
@ -92,9 +85,10 @@ export const Dropdown = ({
flip(),
size({
padding: 32,
apply: ({ availableHeight }) => {
apply: () => {
flushSync(() => {
setDropdownMaxHeight(availableHeight);
// TODO: I think this is not needed anymore let's remove it if not used for a few weeks
// setDropdownMaxHeight(availableHeight);
});
},
boundary: document.querySelector('#root') ?? undefined,

View File

@ -11,7 +11,7 @@ const StyledDropdownMenuItemsExternalContainer = styled.div<{
display: flex;
flex-direction: column;
max-height: ${({ hasMaxHeight }) => (hasMaxHeight ? '188px' : 'none')};
max-height: ${({ hasMaxHeight }) => (hasMaxHeight ? '168px' : 'none')};
padding: var(--padding);
@ -72,7 +72,6 @@ export const DropdownMenuItemsContainer = ({
<ScrollWrapper
contextProviderName="dropdownMenuItemsContainer"
componentInstanceId={`scroll-wrapper-dropdown-menu-${id}`}
heightMode="fit-content"
>
<StyledDropdownMenuItemsExternalContainer
hasMaxHeight={hasMaxHeight}