Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(button): link doesn't work when it's inside the data-grid (VIV-1587) #1612

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions libs/components/src/lib/button/button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ describe('vwc-button', () => {
});
});

describe('click', () => {
it('should open the href if set', async () => {
const spy = jest.spyOn(window, 'open');

const href = '/somewhere';
element.label = 'Link text';
element.href = href;
await elementUpdated(element);

getControlElement(element).click();
await elementUpdated(element);

expect(spy).toHaveBeenCalled();
});
});


describe('disabled', function () {
it('should set disabled class when disabled is true', async () => {
const appearance = 'filled';
Expand Down
2 changes: 1 addition & 1 deletion libs/components/src/lib/button/button.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Size } from '../enums';
import { affixIconTemplateFactory, IconAriaHidden, IconWrapper } from '../../shared/patterns/affix';
import type { Button, ButtonAppearance, ButtonSize } from './button';


const getAppearanceClassName = (appearance: ButtonAppearance, disabled: boolean) => {
let className = `appearance-${appearance}`;
disabled && (className += ' disabled');
Expand Down Expand Up @@ -111,6 +110,7 @@ function renderAnchorContent(context: ElementDefinitionContext) {
aria-live="${x => x.ariaLive}"
aria-relevant="${x => x.ariaRelevant}"
aria-roledescription="${x => x.ariaRoledescription}"
@click="${(x) => window.open(x.href, x.target || '_self')}"
${ref('control')}>
${x => renderIconOrPending(context, x.icon, x.pending, x.size)}
${when(x => x.label, html`<span class="text" role="presentation">${(x) => x.label}</span>`)}
Expand Down
Loading