0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 09:14:46 +01:00

feat(flags): improve the LemonInputSelect component so that new elements 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>
This commit is contained in:
Dylan Martin 2024-08-12 05:20:20 -04:00 committed by GitHub
parent 12bd51fd54
commit dec06090e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) => {
@ -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.