fix(native-filters): Infinite load when filter with default first value is out of scope in horizontal bar (#24542)

This commit is contained in:
Kamil Gabryjelski 2023-06-28 16:29:29 +02:00 committed by GitHub
parent a846e8a58d
commit 262b769d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 4 deletions

View File

@ -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 };
@ -120,6 +124,7 @@ const DropdownContainer = forwardRef(
dropdownTriggerIcon,
dropdownTriggerText = t('More'),
dropdownTriggerTooltip = null,
forceRender,
style,
}: DropdownContainerProps,
outerRef: RefObject<Ref>,
@ -364,7 +369,7 @@ const DropdownContainer = forwardRef(
visible={popoverVisible}
onVisibleChange={visible => setPopoverVisible(visible)}
placement="bottom"
destroyTooltipOnHide
forceRender={forceRender}
>
<Tooltip title={dropdownTriggerTooltip}>
<Button

View File

@ -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">

View File

@ -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} />;

View File

@ -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';

View File

@ -277,6 +277,7 @@ const FilterControls: FC<FilterControlsProps> = ({
)
: undefined
}
forceRender={hasRequiredFirst}
ref={popoverRef}
onOverflowingStateChange={({ overflowed: nextOverflowedIds }) => {
if (