Skip to content

Commit

Permalink
Fix: allow pill anchor target to remain unspecified (viamrobotics#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Nov 12, 2024
1 parent 5c0cef3 commit bb60e1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/prime-core",
"version": "0.0.165",
"version": "0.0.166",
"repository": {
"type": "git",
"url": "https://github.com/viamrobotics/prime.git",
Expand Down
18 changes: 14 additions & 4 deletions packages/core/src/lib/__tests__/pill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,20 @@ describe('Pill', () => {

it('Renders with the passed href', () => {
render(Pill, { value: 'link', href: 'https://www.viam.com' });
expect(screen.getByRole('link', { name: 'link' })).toHaveAttribute(
'href',
'https://www.viam.com'
);
const anchor = screen.getByRole('link', { name: 'link' });

expect(anchor).toHaveAttribute('href', 'https://www.viam.com');
expect(anchor).not.toHaveAttribute('target');
});

it('May set anchor target', () => {
render(Pill, {
props: { value: 'link', href: 'https://www.viam.com', target: '_blank' },
});
const anchor = screen.getByRole('link', { name: 'link' });

expect(anchor).toHaveAttribute('href', 'https://www.viam.com');
expect(anchor).toHaveAttribute('target', '_blank');
});

it('Renders icon tooltip when hovered', async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/lib/pill.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export let value = '';
export let href = '';
/** Optional target for linked URL. */
export let target: '_self' | '_blank' | '_parent' | '_top' = '_blank';
export let target: '_self' | '_blank' | '_parent' | '_top' | undefined =
undefined;
/** Whether or not the pill has the aria-readonly attribute. If readonly, there is not a button to remove the pill. */
export let readonly = false;
Expand Down

0 comments on commit bb60e1c

Please sign in to comment.