Skip to content
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: Popover closes on change of dropdowns values #12410

Merged
merged 12 commits into from
Jan 14, 2021
Merged
9 changes: 2 additions & 7 deletions superset-frontend/src/components/Select/OnPasteSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ export default class OnPasteSelect extends React.Component {

render() {
const { selectWrap: SelectComponent, ...restProps } = this.props;
return (
<SelectComponent
{...restProps}
onPaste={this.onPaste}
menuPortalTarget={document.body}
/>
);
return <SelectComponent {...restProps} onPaste={this.onPaste} />;
}
}

Expand All @@ -98,6 +92,7 @@ OnPasteSelect.propTypes = {
value: PropTypes.any,
isValidNewOption: PropTypes.func,
noResultsText: PropTypes.string,
forceOverflow: PropTypes.bool,
};
OnPasteSelect.defaultProps = {
separator: [',', '\n', '\t', ';'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type SupersetStyledSelectProps<
valueRenderedAsLabel?: boolean;
// callback for paste event
onPaste?: (e: SyntheticEvent) => void;
forceOverflow?: boolean;
// for simplier theme overrides
themeConfig?: PartialThemeConfig;
stylesConfig?: PartialStylesConfig;
Expand Down Expand Up @@ -146,6 +147,7 @@ function styled<
multi = false, // same as `isMulti`, used for backward compatibility
clearable, // same as `isClearable`
sortable = true, // whether to enable drag & drop sorting
forceOverflow, // whether the dropdown should be forcefully overflowing

// react-select props
className = DEFAULT_CLASS_NAME,
Expand Down Expand Up @@ -177,6 +179,7 @@ function styled<
}
return optionRenderer ? optionRenderer(option) : getOptionLabel(option);
},

...restProps
} = selectProps;

Expand Down Expand Up @@ -216,8 +219,6 @@ function styled<
Object.assign(restProps, sortableContainerProps);
}

stylesConfig.menuPortal = base => ({ ...base, zIndex: 9999 });

// When values are rendered as labels, adjust valueContainer padding
const valueRenderedAsLabel =
valueRenderedAsLabel_ === undefined ? isMulti : valueRenderedAsLabel_;
Expand All @@ -243,6 +244,18 @@ function styled<
});
}

// handle forcing dropdown overflow
// use only when setting overflow:visible isn't possible on the container element
if (forceOverflow) {
geido marked this conversation as resolved.
Show resolved Hide resolved
Object.assign(restProps, {
closeMenuOnScroll: (e: Event) => {
const target = e.target as HTMLElement;
return target && !target.classList?.contains('Select__menu-list');
},
menuPosition: 'fixed',
});
}

// Make sure always return StateManager for the refs.
// To get the real `Select` component, keep tap into `obj.select`:
// - for normal <Select /> component: StateManager -> Select,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class RefreshIntervalModal extends React.PureComponent<
options={options}
value={{ value: refreshFrequency }}
onChange={this.handleFrequencyChange}
forceOverflow
/>
{showRefreshWarning && (
<RefreshWarningContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const propTypes = {
menuPortalTarget: PropTypes.element,
menuPosition: PropTypes.string,
menuPlacement: PropTypes.string,
forceOverflow: PropTypes.bool,
};

const defaultProps = {
Expand Down Expand Up @@ -218,7 +219,6 @@ export default class SelectControl extends React.PureComponent {
filterOption,
isLoading,
menuPlacement,
menuPosition,
name,
noResultsText,
onFocus,
Expand All @@ -227,6 +227,9 @@ export default class SelectControl extends React.PureComponent {
value,
valueKey,
valueRenderer,
forceOverflow,
menuPortalTarget,
menuPosition,
} = this.props;

const optionsRemaining = this.optionsRemaining();
Expand All @@ -251,7 +254,8 @@ export default class SelectControl extends React.PureComponent {
isMulti,
labelKey: 'label',
menuPlacement,
menuPortalTarget: document.body,
forceOverflow,
menuPortalTarget,
menuPosition,
name: `select-${name}`,
noResultsText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ class FilterBox extends React.PureComponent {
: CreatableSelect
}
noResultsText={t('No results found')}
forceOverflow
/>
);
}
Expand Down