Skip to content

Commit 73dd55b

Browse files
committed
feat: Add dimiss popover function
1 parent 37bc083 commit 73dd55b

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/popover/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import React, { useRef } from 'react';
3+
import React from 'react';
44

55
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
66

7-
import useForwardFocus from '../internal/hooks/forward-focus';
87
import useBaseComponent from '../internal/hooks/use-base-component';
98
import { isDevelopment } from '../internal/is-development';
109
import { applyDisplayName } from '../internal/utils/apply-display-name';
1110
import { getExternalProps } from '../internal/utils/external-props';
1211
import { PopoverProps } from './interfaces';
13-
import InternalPopover, { InternalPopoverRef } from './internal';
12+
import InternalPopover from './internal';
1413

1514
export { PopoverProps };
1615

@@ -40,12 +39,9 @@ const Popover = React.forwardRef(
4039
});
4140
const externalProps = getExternalProps(rest);
4241

43-
const internalRef = useRef<InternalPopoverRef | null>(null);
44-
useForwardFocus(ref, internalRef);
45-
4642
return (
4743
<InternalPopover
48-
ref={internalRef}
44+
ref={ref}
4945
header={header}
5046
position={position}
5147
size={size}

src/popover/internal.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ export interface InternalPopoverProps extends Omit<PopoverProps, 'triggerType' |
3030
isInline?: boolean;
3131
}
3232

33-
export interface InternalPopoverRef {
34-
focus: HTMLElement['focus'];
35-
}
36-
3733
export default React.forwardRef(InternalPopover);
3834

3935
function InternalPopover(
@@ -59,7 +55,7 @@ function InternalPopover(
5955

6056
...restProps
6157
}: InternalPopoverProps,
62-
ref: React.Ref<InternalPopoverRef>
58+
ref: React.Ref<PopoverProps.Ref>
6359
) {
6460
const baseProps = getBaseProps(restProps);
6561
const triggerRef = useRef<HTMLElement | null>(null);

src/property-filter/filtering-token/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212

1313
import InternalIcon from '../../icon/internal';
1414
import { useListFocusController } from '../../internal/hooks/use-list-focus-controller';
15-
import InternalPopover, { InternalPopoverProps, InternalPopoverRef } from '../../popover/internal';
15+
import { PopoverProps } from '../../popover/interfaces';
16+
import InternalPopover, { InternalPopoverProps } from '../../popover/internal';
1617
import InternalSelect from '../../select/internal';
1718
import { GeneratedAnalyticsMetadataPropertyEditStart } from '../analytics-metadata/interfaces';
1819

@@ -96,7 +97,7 @@ const FilteringToken = forwardRef(
9697
fallbackSelector: `.${styles.root}`,
9798
});
9899

99-
const popoverRef = useRef<InternalPopoverRef>(null);
100+
const popoverRef = useRef<PopoverProps.Ref>(null);
100101
const popoverProps: InternalPopoverProps = {
101102
content: editorContent,
102103
triggerType: 'text',

0 commit comments

Comments
 (0)