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: Remove the Trigger and Close from the Popover because of gesture conflict #3683

Merged
merged 1 commit into from
Oct 23, 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
22 changes: 14 additions & 8 deletions packages/components/src/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function Popover({
renderContent,
floatingPanelProps,
sheetProps,
onOpenChange,
...props
}: PopoverProps) {
const { bottom } = useSafeAreaInsets();
Expand Down Expand Up @@ -67,7 +68,13 @@ export function Popover({
}

return (
<TMPopover offset={8} allowFlip placement="bottom-end" {...props}>
<TMPopover
offset={8}
allowFlip
placement="bottom-end"
onOpenChange={onOpenChange}
{...props}
>
<TMPopover.Trigger asChild>{renderTrigger}</TMPopover.Trigger>

{/* floating panel */}
Expand Down Expand Up @@ -131,13 +138,12 @@ export function Popover({
<Text variant="$headingXl" color="$text">
{title}
</Text>
<TMPopover.Close asChild>
<IconButton
icon="CrossedSmallOutline"
size="small"
$platform-native={{ hitSlop: 8 }}
/>
</TMPopover.Close>
<IconButton
icon="CrossedSmallOutline"
size="small"
$platform-native={{ hitSlop: 8 }}
onPress={() => onOpenChange(false)}
/>
</XStack>

{/* divider */}
Expand Down
68 changes: 39 additions & 29 deletions packages/kit/src/views/Components/stories/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
import { useState } from 'react';

import { Button, Popover, Stack, Text } from '@onekeyhq/components';

import { Layout } from './utils/Layout';

const PopoverGallery = () => (
<Layout
description=".."
suggestions={['...']}
boundaryConditions={['...']}
elements={[
{
title: 'Default',
element: (
<Popover
title="Popover Demo"
renderTrigger={<Button>Open</Button>}
renderContent={
<Stack space="$4" p="$5">
<Text>
Non exercitation ea laborum cupidatat sunt amet aute
exercitation occaecat minim incididunt non est est voluptate.
</Text>
<Popover.Close>
<Button variant="primary">Button</Button>
</Popover.Close>
</Stack>
}
/>
),
},
]}
/>
);
const PopoverGallery = () => {
const [isOpen, setIsOpen] = useState(false);
return (
<Layout
description=".."
suggestions={['...']}
boundaryConditions={['...']}
elements={[
{
title: 'Default',
element: (
<Popover
title="Popover Demo"
open={isOpen}
onOpenChange={setIsOpen}
renderTrigger={
<Button onPress={() => setIsOpen(true)}>Open</Button>
}
renderContent={
<Stack space="$4" p="$5">
<Text>
Non exercitation ea laborum cupidatat sunt amet aute
exercitation occaecat minim incididunt non est est
voluptate.
</Text>
<Button variant="primary" onPress={() => setIsOpen(false)}>
Button
</Button>
</Stack>
}
/>
),
},
]}
/>
);
};

export default PopoverGallery;