Skip to content

Commit

Permalink
feat(flags): improve the LemonInputSelect component so that new eleme…
Browse files Browse the repository at this point in the history
…nts being added appear at the top of the list, not the bottom (#24301)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
dmarticus and github-actions[bot] authored Aug 12, 2024
1 parent 12bd51f commit dec0609
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function LemonInputSelect({

// We show the input value if custom values are allowed and it's not in the list
if (allowCustomValues && inputValue && !values.includes(inputValue)) {
customValues.unshift(inputValue.replace('\\,', ',')) // Transform escaped commas to plain commas
res.push({ key: inputValue.replace('\\,', ','), label: inputValue.replace('\\,', ',') }) // Transform escaped commas to plain commas
}

options.forEach((option) => {
Expand All @@ -94,13 +94,14 @@ export function LemonInputSelect({
res.push(option)
})

// Custom values are always shown before the list
// Custom values are now added after the input value but before other options
if (customValues.length) {
customValues.forEach((value) => {
res.unshift({ key: value, label: value })
if (value !== inputValue) {
res.splice(1, 0, { key: value, label: value })
}
})
}

// :HACKY: This is a quick fix to make the select dropdown work for large values,
// as it was getting slow when we'd load more than ~10k entries. Ideally we'd
// make this a virtualized list.
Expand Down

0 comments on commit dec0609

Please sign in to comment.