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:
@ -2,7 +2,7 @@ import styled from '@emotion/styled';
|
|||||||
|
|
||||||
export const StyledDropdownMenu = styled.div<{
|
export const StyledDropdownMenu = styled.div<{
|
||||||
disableBlur?: boolean;
|
disableBlur?: boolean;
|
||||||
width?: number;
|
width?: `${string}px` | 'auto' | number;
|
||||||
}>`
|
}>`
|
||||||
backdrop-filter: ${({ disableBlur }) =>
|
backdrop-filter: ${({ disableBlur }) =>
|
||||||
disableBlur ? 'none' : 'blur(20px)'};
|
disableBlur ? 'none' : 'blur(20px)'};
|
||||||
@ -16,9 +16,8 @@ export const StyledDropdownMenu = styled.div<{
|
|||||||
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
min-width: 160px;
|
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
width: ${({ width }) => (width ? `${width}px` : 'auto')};
|
width: ${({ width }) =>
|
||||||
|
width ? `${typeof width === 'number' ? `${width}px` : width}` : '160px'};
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ type OwnProps = {
|
|||||||
resetState?: () => void;
|
resetState?: () => void;
|
||||||
HotkeyScope: string;
|
HotkeyScope: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
menuWidth?: `${string}px` | 'auto' | number;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledDropdownButtonContainer = styled.div`
|
const StyledDropdownButtonContainer = styled.div`
|
||||||
@ -66,6 +67,7 @@ function DropdownButton({
|
|||||||
HotkeyScope,
|
HotkeyScope,
|
||||||
icon,
|
icon,
|
||||||
color,
|
color,
|
||||||
|
menuWidth,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Enter, Key.Escape],
|
[Key.Enter, Key.Escape],
|
||||||
@ -97,7 +99,11 @@ function DropdownButton({
|
|||||||
{label}
|
{label}
|
||||||
</StyledDropdownButton>
|
</StyledDropdownButton>
|
||||||
{isUnfolded && (
|
{isUnfolded && (
|
||||||
<DropdownMenuContainer anchor={anchor} onClose={onOutsideClick}>
|
<DropdownMenuContainer
|
||||||
|
width={menuWidth}
|
||||||
|
anchor={anchor}
|
||||||
|
onClose={onOutsideClick}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</DropdownMenuContainer>
|
</DropdownMenuContainer>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -19,12 +19,14 @@ export type DropdownMenuContainerProps = {
|
|||||||
anchor?: 'left' | 'right';
|
anchor?: 'left' | 'right';
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
|
width?: `${string}px` | 'auto' | number;
|
||||||
} & HTMLAttributes<HTMLUListElement>;
|
} & HTMLAttributes<HTMLUListElement>;
|
||||||
|
|
||||||
export function DropdownMenuContainer({
|
export function DropdownMenuContainer({
|
||||||
anchor = 'right',
|
anchor = 'right',
|
||||||
children,
|
children,
|
||||||
onClose,
|
onClose,
|
||||||
|
width,
|
||||||
...props
|
...props
|
||||||
}: DropdownMenuContainerProps) {
|
}: DropdownMenuContainerProps) {
|
||||||
const dropdownRef = useRef(null);
|
const dropdownRef = useRef(null);
|
||||||
@ -38,7 +40,9 @@ export function DropdownMenuContainer({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDropdownMenuContainer data-select-disable {...props} anchor={anchor}>
|
<StyledDropdownMenuContainer data-select-disable {...props} anchor={anchor}>
|
||||||
<StyledDropdownMenu ref={dropdownRef}>{children}</StyledDropdownMenu>
|
<StyledDropdownMenu ref={dropdownRef} width={width}>
|
||||||
|
{children}
|
||||||
|
</StyledDropdownMenu>
|
||||||
</StyledDropdownMenuContainer>
|
</StyledDropdownMenuContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,6 +112,12 @@ export function MultipleFiltersDropdownButton({
|
|||||||
onIsUnfoldedChange={handleIsUnfoldedChange}
|
onIsUnfoldedChange={handleIsUnfoldedChange}
|
||||||
HotkeyScope={HotkeyScope}
|
HotkeyScope={HotkeyScope}
|
||||||
color={color}
|
color={color}
|
||||||
|
menuWidth={
|
||||||
|
selectedOperandInDropdown &&
|
||||||
|
filterDefinitionUsedInDropdown?.type === 'date'
|
||||||
|
? 'auto'
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{!filterDefinitionUsedInDropdown ? (
|
{!filterDefinitionUsedInDropdown ? (
|
||||||
<FilterDropdownFilterSelect context={context} />
|
<FilterDropdownFilterSelect context={context} />
|
||||||
|
|||||||
Reference in New Issue
Block a user