fix: drop down menu should be of 160px size (#1459)

* fix: drop down menu should be of 160px size

* fix: typing

* fix: remove debug
This commit is contained in:
Jérémy M 2023-09-05 17:38:07 +02:00 committed by GitHub
parent b3887c6bcc
commit 21e3f6ecb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import styled from '@emotion/styled';
export const StyledDropdownMenu = styled.div<{
disableBlur?: boolean;
width?: number;
width?: `${string}px` | 'auto' | number;
}>`
backdrop-filter: ${({ disableBlur }) =>
disableBlur ? 'none' : 'blur(20px)'};
@ -16,9 +16,8 @@ export const StyledDropdownMenu = styled.div<{
flex-direction: column;
min-width: 160px;
overflow: hidden;
width: ${({ width }) => (width ? `${width}px` : 'auto')};
width: ${({ width }) =>
width ? `${typeof width === 'number' ? `${width}px` : width}` : '160px'};
`;

View File

@ -17,6 +17,7 @@ type OwnProps = {
resetState?: () => void;
HotkeyScope: string;
color?: string;
menuWidth?: `${string}px` | 'auto' | number;
};
const StyledDropdownButtonContainer = styled.div`
@ -66,6 +67,7 @@ function DropdownButton({
HotkeyScope,
icon,
color,
menuWidth,
}: OwnProps) {
useScopedHotkeys(
[Key.Enter, Key.Escape],
@ -97,7 +99,11 @@ function DropdownButton({
{label}
</StyledDropdownButton>
{isUnfolded && (
<DropdownMenuContainer anchor={anchor} onClose={onOutsideClick}>
<DropdownMenuContainer
width={menuWidth}
anchor={anchor}
onClose={onOutsideClick}
>
{children}
</DropdownMenuContainer>
)}

View File

@ -19,12 +19,14 @@ export type DropdownMenuContainerProps = {
anchor?: 'left' | 'right';
children: React.ReactNode;
onClose?: () => void;
width?: `${string}px` | 'auto' | number;
} & HTMLAttributes<HTMLUListElement>;
export function DropdownMenuContainer({
anchor = 'right',
children,
onClose,
width,
...props
}: DropdownMenuContainerProps) {
const dropdownRef = useRef(null);
@ -38,7 +40,9 @@ export function DropdownMenuContainer({
return (
<StyledDropdownMenuContainer data-select-disable {...props} anchor={anchor}>
<StyledDropdownMenu ref={dropdownRef}>{children}</StyledDropdownMenu>
<StyledDropdownMenu ref={dropdownRef} width={width}>
{children}
</StyledDropdownMenu>
</StyledDropdownMenuContainer>
);
}

View File

@ -112,6 +112,12 @@ export function MultipleFiltersDropdownButton({
onIsUnfoldedChange={handleIsUnfoldedChange}
HotkeyScope={HotkeyScope}
color={color}
menuWidth={
selectedOperandInDropdown &&
filterDefinitionUsedInDropdown?.type === 'date'
? 'auto'
: undefined
}
>
{!filterDefinitionUsedInDropdown ? (
<FilterDropdownFilterSelect context={context} />