Skip to content

Commit

Permalink
chore(frontend): Avoid flaky JS breakpoint in `TaxonomicPropertyFilte…
Browse files Browse the repository at this point in the history
…r` (#23129)
  • Loading branch information
Twixes authored and thmsobrmlr committed Jun 24, 2024
1 parent 74be403 commit 237f437
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 83 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.PropertyFilters__prefix {
padding: 0 5px;
font-size: 18px;
color: #c4c4c4;
color: var(--border-bold-3000);
user-select: none;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ export function OperatorValueSelect({
/>
</div>
{!isOperatorFlag(currentOperator || PropertyOperator.Exact) && type && propkey && (
<div className="flex-1 min-w-[10rem]" data-attr="taxonomic-value-select">
<div
className={
// High flex-grow for proper sizing within TaxonomicPropertyFilter
'shrink grow-[1000] min-w-[10rem]'
}
data-attr="taxonomic-value-select"
>
<PropertyValue
type={type}
key={propkey}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,59 @@
max-width: 100%;
background: var(--bg-light);

.TaxonomicPropertyFilter__row__items {
.TaxonomicPropertyFilter__row-items {
> :first-child {
width: 10rem;
}
}
}
}

.TaxonomicPropertyFilter__row {
display: flex;
gap: 0.5rem;
overflow: hidden;

.TaxonomicPropertyFilter__row__operator {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: flex-end;
width: 4.5rem;
height: 40px; // Matches typical row height

.arrow {
position: relative;
font-size: 18px;
font-weight: bold;
color: #c4c4c4;
user-select: none;
}
}

.TaxonomicPropertyFilter__row__items {
display: flex;
flex: 1;
flex-wrap: wrap;
gap: 0.5rem;
align-items: flex-start;
overflow: hidden;
.TaxonomicPropertyFilter__row {
display: flex;
gap: 0.5rem;
overflow: hidden;
}

> * {
max-width: 100%;
overflow: hidden;
}
}
.TaxonomicPropertyFilter__row-operator {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: flex-end;
width: 4.5rem;
height: 40px; // Matches typical row height

&.TaxonomicPropertyFilter__row--showing-operators {
// Mobile screen - columns
&.width-tiny {
.TaxonomicPropertyFilter__row__items {
flex-direction: column;
align-items: stretch;
}
}
.TaxonomicPropertyFilter__row--or-filtering & {
width: 2rem;
}
}

// small size - force wrapping
&.width-small {
.TaxonomicPropertyFilter__row__items {
> :first-child {
flex: 1;
min-width: 10rem;
}
.TaxonomicPropertyFilter__row-arrow {
position: relative;
font-size: 18px;
font-weight: bold;
color: var(--border-bold-3000);
user-select: none;
}

> :last-child {
width: 100%;
}
}
}
.TaxonomicPropertyFilter__row-items {
display: flex;
flex: 1;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
overflow: hidden;

&.width-medium {
.TaxonomicPropertyFilter__row__items {
> :first-child {
width: 30%;
min-width: 10rem;
}
}
}
}
> * {
max-width: 100%;
overflow: hidden;
}

&.TaxonomicPropertyFilter__row--or-filtering {
.TaxonomicPropertyFilter__row__operator {
width: 2rem;
}
.TaxonomicPropertyFilter__row--showing-operators & {
> :first-child {
flex-grow: 1;
width: 30%;
min-width: 10rem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
TaxonomicFilterGroupType,
TaxonomicFilterValue,
} from 'lib/components/TaxonomicFilter/types'
import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver'
import { isOperatorMulti, isOperatorRegex } from 'lib/utils'
import { useMemo } from 'react'

Expand Down Expand Up @@ -118,31 +117,23 @@ export function TaxonomicPropertyFilter({
/>
)

const { ref: wrapperRef, size } = useResizeBreakpoints({
0: 'tiny',
350: 'small',
550: 'medium',
})

return (
<div
className={clsx('TaxonomicPropertyFilter', {
'TaxonomicPropertyFilter--in-dropdown': !showInitialSearchInline && !disablePopover,
})}
ref={wrapperRef}
>
{showInitialSearchInline ? (
taxonomicFilter
) : (
<div
className={clsx('TaxonomicPropertyFilter__row', {
[`width-${size}`]: true,
'TaxonomicPropertyFilter__row--or-filtering': orFiltering,
'TaxonomicPropertyFilter__row--showing-operators': showOperatorValueSelect,
})}
>
{hasRowOperator && (
<div className="TaxonomicPropertyFilter__row__operator">
<div className="TaxonomicPropertyFilter__row-operator">
{orFiltering ? (
<>
{propertyGroupType && index !== 0 && filter?.key && (
Expand All @@ -155,7 +146,7 @@ export function TaxonomicPropertyFilter({
<div className="flex items-center gap-1">
{index === 0 ? (
<>
<span className="arrow">&#8627;</span>
<span className="TaxonomicPropertyFilter__row-arrow">&#8627;</span>
<span>where</span>
</>
) : (
Expand All @@ -165,7 +156,7 @@ export function TaxonomicPropertyFilter({
)}
</div>
)}
<div className="TaxonomicPropertyFilter__row__items">
<div className="TaxonomicPropertyFilter__row-items">
<LemonDropdown
overlay={taxonomicFilter}
placement="bottom-start"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/surveys/Surveys.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export const NewSurveyTargetingSection: StoryFn = () => {
}
NewSurveyTargetingSection.parameters = {
testOptions: {
waitForSelector: ['.LemonBanner .LemonIcon', '.TaxonomicPropertyFilter__row.width-small'],
waitForSelector: ['.LemonBanner .LemonIcon', '.TaxonomicPropertyFilter__row'],
},
}

Expand Down

0 comments on commit 237f437

Please sign in to comment.