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

feat: Change Popover to use min width when matching #21039

Merged
merged 3 commits into from
Mar 25, 2024
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
2 changes: 1 addition & 1 deletion frontend/src/lib/components/MemberSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function MemberSelect({ defaultLabel = 'Any user', value, onChange }: Mem
<LemonDropdown
closeOnClickInside={false}
visible={showPopover}
sameWidth={false}
matchWidth={false}
actionable
onVisibilityChange={(visible) => setShowPopover(visible)}
overlay={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function TaxonomicPopover<ValueType extends TaxonomicFilterValue = Taxono
excludedProperties={excludedProperties}
/>
}
sameWidth={false}
matchWidth={false}
actionable
visible={visible}
onClickOutside={() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/lemon-ui/LemonButton/LemonButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

type PopoverStory = StoryObj<typeof LemonButtonWithDropdown>
const PopoverTemplate: StoryFn<typeof LemonButtonWithDropdown> = (props: LemonButtonWithDropdownProps) => {
return <LemonButtonWithDropdown {...props} />

Check warning on line 86 in frontend/src/lib/lemon-ui/LemonButton/LemonButton.stories.tsx

View workflow job for this annotation

GitHub Actions / Code quality checks

<LemonButtonWithDropdown> is forbidden, use <LemonMenu> with a <LemonButton> child instead
}

export const NoPadding = (): JSX.Element => {
Expand Down Expand Up @@ -386,7 +386,7 @@
</>
),
placement: 'bottom',
sameWidth: true,
matchWidth: true,
},
}

Expand All @@ -404,7 +404,7 @@
</>
),
placement: 'bottom',
sameWidth: true,
matchWidth: true,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function LemonInputSelect({

return (
<LemonDropdown
sameWidth
matchWidth
closeOnClickInside={false}
actionable
visible={showPopover}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/lemon-ui/LemonMenu/LemonMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface LemonMenuProps
LemonDropdownProps,
| 'placement'
| 'fallbackPlacements'
| 'sameWidth'
| 'matchWidth'
| 'maxContentWidth'
| 'visible'
| 'onVisibilityChange'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/lemon-ui/LemonSelect/LemonSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function LemonSelect<T extends string | number | boolean | null>({
<LemonMenu
items={items}
tooltipPlacement={optionTooltipPlacement}
sameWidth={dropdownMatchSelectWidth}
matchWidth={dropdownMatchSelectWidth}
placement={dropdownPlacement}
className={menu?.className}
maxContentWidth={dropdownMaxContentWidth}
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/lib/lemon-ui/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export interface PopoverProps {
fallbackPlacements?: Placement[]
/** Whether the popover is actionable rather than just informative - actionable means a colored border. */
actionable?: boolean
/** Whether the popover's width should be synced with the children's width. */
sameWidth?: boolean
/** Whether the popover's width should be synced with the children's width or bigger. */
matchWidth?: boolean
maxContentWidth?: boolean
className?: string
/** Whether default box padding should be applies. @default true */
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Popover = React.forwardRef<HTMLDivElement, PopoverProps>(function P
className,
padded = true,
middleware,
sameWidth = false,
matchWidth = false,
maxContentWidth = false,
additionalRefs = [],
closeParentPopoverOnClickInside = false,
Expand Down Expand Up @@ -131,7 +131,10 @@ export const Popover = React.forwardRef<HTMLDivElement, PopoverProps>(function P
apply({ availableWidth, availableHeight, rects, elements: { floating } }) {
floating.style.maxHeight = `${availableHeight}px`
floating.style.maxWidth = `${availableWidth}px`
floating.style.width = sameWidth ? `${rects.reference.width}px` : 'initial'
floating.style.width = 'initial'
if (matchWidth) {
floating.style.minWidth = `${rects.reference.width}px`
}
},
}),
...(showArrow ? [arrow({ element: arrowRef, padding: 8 })] : []),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/nodes/DataTable/SavedQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function SavedQueries({ query, setQuery }: SavedQueriesProps): JSX.Elemen
return (
<LemonButtonWithDropdown
dropdown={{
sameWidth: false,
matchWidth: false,
overlay: Object.entries(eventsQueries).map(([title, eventsQuery]) => (
<LemonButton
key={title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function PathsEventsTypes({ insightProps }: EditorFilterProps): JSX.Eleme
fullWidth
type="secondary"
dropdown={{
sameWidth: true,
matchWidth: true,
closeOnClickInside: false,
overlay: options.map((option) => (
<LemonButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function FunnelBinsPicker(): JSX.Element {
<>
<LemonDropdown
data-attr="funnel-bin-filter"
sameWidth
matchWidth
visible={visible}
closeOnClickInside={false}
onClickOutside={() => setVisible(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export function NotebookSelectPopover({
<NotebookSelectList {...props} onNotebookOpened={onNotebookOpened} />
</div>
}
sameWidth={false}
matchWidth={false}
actionable
visible={!!showPopover}
onVisibilityChange={(visible) => setShowPopover(visible)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function ConsoleFilters({
data-attr="console-filters"
fullWidth={true}
dropdown={{
sameWidth: true,
matchWidth: true,
closeOnClickInside: false,
overlay: [
<>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3042,7 +3042,7 @@ interface BreadcrumbBase {
/** Symbol, e.g. a lettermark or a profile picture. */
symbol?: React.ReactNode
/** Whether to show a custom popover */
popover?: Pick<PopoverProps, 'overlay' | 'sameWidth'>
popover?: Pick<PopoverProps, 'overlay' | 'matchWidth'>
}
interface LinkBreadcrumb extends BreadcrumbBase {
/** Path to link to. */
Expand Down
Loading