mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 05:18:11 +08:00
Fix duplicated dropdown selection styling when multiple entries have identical labels (#4180)
* Fix dropdown select if options have identical labels * update other uses of label in favor of value * simplify null checks
This commit is contained in:
@@ -97,7 +97,7 @@
|
|||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
const flattened = filteredEntries.flat();
|
const flattened = filteredEntries.flat();
|
||||||
const highlightedFound = highlighted?.label && flattened.map((entry) => entry.label).includes(highlighted.label);
|
const highlightedFound = flattened.map((entry) => entry.value).includes(highlighted.value);
|
||||||
const newHighlighted = highlightedFound ? highlighted : flattened[0];
|
const newHighlighted = highlightedFound ? highlighted : flattened[0];
|
||||||
setHighlighted(newHighlighted);
|
setHighlighted(newHighlighted);
|
||||||
}
|
}
|
||||||
@@ -335,7 +335,7 @@
|
|||||||
if ((menuOpen || interactive) && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
if ((menuOpen || interactive) && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
||||||
let newIndex = e.key === "ArrowUp" ? flatEntries.length - 1 : 0;
|
let newIndex = e.key === "ArrowUp" ? flatEntries.length - 1 : 0;
|
||||||
if (highlighted) {
|
if (highlighted) {
|
||||||
const index = highlighted ? flatEntries.map((entry) => entry.label).indexOf(highlighted.label) : 0;
|
const index = flatEntries.map((entry) => entry.value).indexOf(highlighted.value);
|
||||||
newIndex = index + (e.key === "ArrowUp" ? -1 : 1);
|
newIndex = index + (e.key === "ArrowUp" ? -1 : 1);
|
||||||
|
|
||||||
// Interactive dropdowns should lock at the end whereas other dropdowns should loop
|
// Interactive dropdowns should lock at the end whereas other dropdowns should loop
|
||||||
@@ -482,7 +482,7 @@
|
|||||||
{#each currentEntries(section, virtualScrollingEntryHeight, virtualScrollingStartIndex, virtualScrollingEndIndex, search) as entry, entryIndex (entryIndex + startIndex)}
|
{#each currentEntries(section, virtualScrollingEntryHeight, virtualScrollingStartIndex, virtualScrollingEndIndex, search) as entry, entryIndex (entryIndex + startIndex)}
|
||||||
<LayoutRow
|
<LayoutRow
|
||||||
class="row"
|
class="row"
|
||||||
classes={{ open: openChildValue === entry.value, active: entry.label === highlighted?.label, disabled: Boolean(entry.disabled) }}
|
classes={{ open: openChildValue === entry.value, active: entry.value === highlighted?.value, disabled: Boolean(entry.disabled) }}
|
||||||
styles={{ height: virtualScrollingEntryHeight || "20px" }}
|
styles={{ height: virtualScrollingEntryHeight || "20px" }}
|
||||||
tooltipLabel={entry.tooltipLabel}
|
tooltipLabel={entry.tooltipLabel}
|
||||||
tooltipDescription={entry.tooltipDescription}
|
tooltipDescription={entry.tooltipDescription}
|
||||||
|
|||||||
Reference in New Issue
Block a user