Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import {
} from './styles';
import {
DEFAULT_SORT_COMPARATOR,
DROPDOWN_ALIGN_BOTTOM,
EMPTY_OPTIONS,
MAX_TAG_COUNT,
TOKEN_SEPARATORS,
Expand Down Expand Up @@ -777,6 +778,7 @@ const Select = forwardRef(
optionRender={option => <Space>{option.label || option.value}</Space>}
oneLine={oneLine}
css={props.css}
dropdownAlign={DROPDOWN_ALIGN_BOTTOM}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @reynoldmorel is there any chance we can add a test for this? If someone changes it or removes it, we can at least catch it (the test will fail)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m concerned that a unit test here would be largely meaningless, at least in the form I can currently imagine. For example, we could spy on or mock the component and assert that dropdownAlign is passed with a specific value, but that feels brittle—those props could change or even be removed in certain scenarios and still be perfectly valid.

The real issue we’re trying to prevent is the dropdown popup overlapping or extending beyond the input when the container shrinks. That behavior isn’t well captured by asserting internal props.

Given that, a visual test seems more appropriate in this case. We can reasonably assume AntD’s dropdown props behave as intended, and focus on validating the actual user-facing behavior instead.

What do you think @gabotorresruiz

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @reynoldmorel, I see your point, but I think adding a test here could still be beneficial for everyone

{...props}
showSearch={shouldShowSearch}
ref={ref}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { LabeledValue as AntdLabeledValue } from 'antd/es/select';
import { t } from '@apache-superset/core';
import { rankedSearchCompare } from '../../utils/rankedSearchCompare';
import { RawValue } from './types';
import { RawValue, SelectProps } from './types';

export const MAX_TAG_COUNT = 4;

Expand All @@ -33,6 +33,12 @@ export const SELECT_ALL_VALUE: RawValue = t('Select All');

export const VIRTUAL_THRESHOLD = 20;

export const DROPDOWN_ALIGN_BOTTOM: SelectProps['dropdownAlign'] = {
points: ['tl', 'bl'],
offset: [0, 4],
overflow: { adjustX: 0, adjustY: 1 },
};

export const SELECT_ALL_OPTION = {
value: SELECT_ALL_VALUE,
label: String(SELECT_ALL_VALUE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type AntdExposedProps = Pick<
| 'virtual'
| 'getPopupContainer'
| 'menuItemSelectedIcon'
| 'dropdownAlign'
>;

export type SelectOptionsType = Exclude<AntdProps['options'], undefined>;
Expand Down
Loading