Skip to content

Commit ef22e00

Browse files
authored
fix: experiment form UX fixes (#8251)
1 parent ed45277 commit ef22e00

4 files changed

Lines changed: 30 additions & 14 deletions

File tree

frontend/web/components/PageTitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const PageTitle: FC<PageTitleType> = ({ children, className, cta, title }) => {
2020
</Row>
2121
)}
2222
</div>
23-
{!!cta && <div className='float-end ms-lg-2'>{cta}</div>}
23+
{!!cta && <div className='float-end'>{cta}</div>}
2424
</div>
2525
<hr className='mb-0 mt-3' />
2626
</div>

frontend/web/components/experiments/EventNameSelect/EventNameSelect.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { FC, useMemo } from 'react'
1+
import { FC, useMemo, useState } from 'react'
22
import CreatableSelect from 'react-select/creatable'
3+
import { InputActionMeta } from 'react-select'
34
import {
45
useGetWarehouseConnectionEventsQuery,
56
useGetWarehouseConnectionsQuery,
@@ -33,6 +34,22 @@ const EventNameSelect: FC<EventNameSelectProps> = ({ onChange, value }) => {
3334
)
3435
const options = useMemo(() => buildEventOptions(data?.events), [data?.events])
3536
const showWarning = isSuccess && isUnknownEvent(value, data?.events)
37+
const [inputValue, setInputValue] = useState('')
38+
39+
// Keep the typed text on blur (react-select discards it by default) so
40+
// clicking outside commits the value instead of clearing it.
41+
const handleInputChange = (val: string, meta: InputActionMeta) => {
42+
if (meta.action === 'input-change') setInputValue(val)
43+
}
44+
const handleChange = (option: EventOption | null) => {
45+
setInputValue('')
46+
onChange(option?.value ?? '')
47+
}
48+
const handleBlur = () => {
49+
if (!inputValue) return
50+
onChange(inputValue)
51+
setInputValue('')
52+
}
3653

3754
return (
3855
<div className='event-name-select'>
@@ -42,11 +59,14 @@ const EventNameSelect: FC<EventNameSelectProps> = ({ onChange, value }) => {
4259
classNamePrefix='react-select'
4360
isClearable
4461
isLoading={isLoading}
62+
inputValue={inputValue}
63+
onInputChange={handleInputChange}
64+
onBlur={handleBlur}
4565
maxMenuHeight={200}
4666
menuPlacement='auto'
4767
options={options}
4868
value={value ? { label: value, value } : null}
49-
onChange={(option: EventOption | null) => onChange(option?.value ?? '')}
69+
onChange={handleChange}
5070
placeholder='e.g. checkout_completed'
5171
formatCreateLabel={(input: string) => `Use "${input}"`}
5272
noOptionsMessage={() => 'Type to add a new event'}

frontend/web/components/experiments/results/ExperimentSummaryScorecard.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ const ExperimentSummaryScorecard: FC<ExperimentSummaryScorecardProps> = ({
5151
loading={!hasResults}
5252
value={
5353
summary?.winnerName ? (
54-
<span
55-
className={summary.controlWins ? undefined : 'text-success'}
56-
>
57-
<VariantName
58-
fit
59-
colour={summary.winnerColour}
60-
fontSize={24}
61-
name={summary.winnerName}
62-
/>
63-
</span>
54+
<VariantName
55+
fit
56+
colour={summary.winnerColour}
57+
fontSize={24}
58+
name={summary.winnerName}
59+
/>
6460
) : undefined
6561
}
6662
/>

frontend/web/components/experiments/steps/SetupStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const SetupStep: FC<SetupStepProps> = ({
4545
search: search || undefined,
4646
type: 'MULTIVARIATE',
4747
},
48-
{ skip: !numericEnvId },
48+
{ refetchOnMountOrArgChange: true, skip: !numericEnvId },
4949
)
5050

5151
const multivariateFeatures = featureList?.results ?? []

0 commit comments

Comments
 (0)