Skip to content

Commit f52de86

Browse files
authored
Add href prop to Combobox to get reactive hrefs working correctly (#2428)
* Add href prop to Combobox to get reactive hrefs working correctly * Use correct hrefDisabled prop
1 parent 3c339b9 commit f52de86

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

Diff for: src/lib/components/top-nav.svelte

+3-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
import DataEncoderStatus from '$lib/components/data-encoder-status.svelte';
55
import TimezoneSelect from '$lib/components/timezone-select.svelte';
6-
import Button from '$lib/holocene/button.svelte';
76
import Combobox from '$lib/holocene/combobox/combobox.svelte';
87
import { translate } from '$lib/i18n/translate';
98
import { lastUsedNamespace } from '$lib/stores/namespaces';
@@ -48,16 +47,9 @@
4847
on:change={handleNamespaceSelect}
4948
minSize={32}
5049
actionTooltip={translate('namespaces.go-to-namespace')}
51-
>
52-
<Button
53-
slot="action"
54-
variant="ghost"
55-
size="xs"
56-
{href}
57-
disabled={!namespaceExists}
58-
leadingIcon="external-link"
59-
/>
60-
</Combobox>
50+
{href}
51+
hrefDisabled={!namespaceExists}
52+
/>
6153
</div>
6254
<div class="flex items-center gap-2">
6355
<TimezoneSelect position={screenWidth < 768 ? 'left' : 'right'} />

Diff for: src/lib/holocene/combobox/combobox.svelte

+27
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import Menu from '$lib/holocene/menu/menu.svelte';
1212
1313
import Badge from '../badge.svelte';
14+
import Button from '../button.svelte';
1415
import Chip from '../chip.svelte';
1516
import type { IconName } from '../icon';
1617
import Icon from '../icon/icon.svelte';
@@ -45,6 +46,8 @@
4546
error?: string;
4647
valid?: boolean;
4748
actionTooltip?: string;
49+
href?: string;
50+
hrefDisabled?: boolean;
4851
}
4952
5053
type MultiSelectProps = {
@@ -109,6 +112,8 @@
109112
export let deselectAllLabel = 'Deselect All';
110113
export let removeChipLabel = 'Remove Option';
111114
export let actionTooltip = '';
115+
export let href = '';
116+
export let hrefDisabled = false;
112117
113118
export let numberOfItemsSelectedLabel = (count: number) =>
114119
`${count} option${count > 1 ? 's' : ''} selected`;
@@ -402,6 +407,28 @@
402407
<slot name="action" />
403408
{/if}
404409
</div>
410+
{:else if href}
411+
<div class="ml-1 flex h-full items-center border-l-2 border-subtle p-0.5">
412+
{#if actionTooltip}
413+
<Tooltip text={actionTooltip} right>
414+
<Button
415+
variant="ghost"
416+
size="xs"
417+
{href}
418+
disabled={hrefDisabled}
419+
leadingIcon="external-link"
420+
/>
421+
</Tooltip>
422+
{:else}
423+
<Button
424+
variant="ghost"
425+
size="xs"
426+
{href}
427+
disabled={hrefDisabled}
428+
leadingIcon="external-link"
429+
/>
430+
{/if}
431+
</div>
405432
{/if}
406433
</div>
407434

0 commit comments

Comments
 (0)