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(native-filters): Infinite load when filter with default first value is out of scope in horizontal bar #24542

Merged
merged 1 commit into from
Jun 28, 2023
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 @@ -104,6 +104,10 @@ export interface DropdownContainerProps {
* Main container additional style properties.
*/
style?: CSSProperties;
/**
* Force render popover content before it's first opened
*/
forceRender?: boolean;
}

export type Ref = HTMLDivElement & { open: () => void };
Expand All @@ -120,6 +124,7 @@ const DropdownContainer = forwardRef(
dropdownTriggerIcon,
dropdownTriggerText = t('More'),
dropdownTriggerTooltip = null,
forceRender,
style,
}: DropdownContainerProps,
outerRef: RefObject<Ref>,
Expand Down Expand Up @@ -364,7 +369,7 @@ const DropdownContainer = forwardRef(
visible={popoverVisible}
onVisibleChange={visible => setPopoverVisible(visible)}
placement="bottom"
destroyTooltipOnHide
forceRender={forceRender}
>
<Tooltip title={dropdownTriggerTooltip}>
<Button
Expand Down
5 changes: 5 additions & 0 deletions superset-frontend/src/components/Popover/Popover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ test('it should not render a title or content when not visible', () => {
expect(title).not.toBeInTheDocument();
});

test('it should render content when not visible but forceRender=true', () => {
render(<Popover content="Content sample" forceRender />);
expect(screen.getByText('Content sample')).toBeInTheDocument();
});

test('renders with icon child', async () => {
render(
<Popover content="Content sample" title="Popover title">
Expand Down
28 changes: 28 additions & 0 deletions superset-frontend/src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { Popover as AntdPopover } from 'antd';
import type { PopoverProps as AntdPopoverProps } from 'antd/lib/popover';

export interface PopoverProps extends AntdPopoverProps {
forceRender?: boolean;
}

export const Popover = (props: PopoverProps) => <AntdPopover {...props} />;
4 changes: 1 addition & 3 deletions superset-frontend/src/components/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Popover } from 'antd';

export type { PopoverProps } from 'antd/lib/popover';
export type { TooltipPlacement } from 'antd/lib/tooltip';

// Eventually Popover can be wrapped and customized in this file
// for now we're just redirecting
export default Popover;
export { Popover as default } from './Popover';
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ const FilterControls: FC<FilterControlsProps> = ({
)
: undefined
}
forceRender={hasRequiredFirst}
ref={popoverRef}
onOverflowingStateChange={({ overflowed: nextOverflowedIds }) => {
if (
Expand Down