@kiva/kv-components 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.0.0...@kiva/kv-components@3.0.1) (2022-02-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **KvButton:** pass through click event for parent ([65c042f](https://github.com/kiva/kv-ui-elements/commit/65c042ff7b4780a514766ab476f443562b195eab))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.0.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@2.0.0...@kiva/kv-components@3.0.0) (2022-02-16)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -68,5 +68,5 @@
68
68
  "optional": true
69
69
  }
70
70
  },
71
- "gitHead": "7006bb2c0026a64f278e727ebae46569e1426c68"
71
+ "gitHead": "2a8ff1a1fb9a3ad59f371d1e938a858e52372c62"
72
72
  }
@@ -1,4 +1,5 @@
1
1
  import { render, fireEvent } from '@testing-library/vue';
2
+ import userEvent from '@testing-library/user-event';
2
3
  import { axe } from 'jest-axe';
3
4
  import addVueRouter from '../../utils/addVueRouter';
4
5
  import KvButton from '../../../../vue/KvButton.vue';
@@ -52,6 +53,29 @@ describe('Default Button', () => {
52
53
  getByTestId('ripple');
53
54
  });
54
55
 
56
+ it('passes through click events', async () => {
57
+ const onClick = jest.fn();
58
+ const { getByText } = render({
59
+ template: `<div>
60
+ <KvButton @click.prevent="onClick">Button tag</KvButton>
61
+ <KvButton href="#test" @click.prevent="onClick">Anchor tag</KvButton>
62
+ <KvButton to="/test" @click.native.prevent="onClick">Router-link</KvButton>
63
+ </div>`,
64
+ components: {
65
+ KvButton,
66
+ },
67
+ methods: {
68
+ onClick,
69
+ },
70
+ }, addVueRouter());
71
+
72
+ // Click all the buttons and expect the onClick method to have been called 3 times
73
+ await userEvent.click(getByText('Button tag'));
74
+ await userEvent.click(getByText('Anchor tag'));
75
+ await userEvent.click(getByText('Router-link'));
76
+ expect(onClick.mock.calls.length).toBe(3);
77
+ });
78
+
55
79
  it('when passed a loading prop, the button is disabled', () => {
56
80
  const { getByRole } = renderTestButton({
57
81
  props: { state: 'loading' },
package/vue/KvButton.vue CHANGED
@@ -242,13 +242,8 @@ export default {
242
242
  };
243
243
 
244
244
  const onClick = (event) => {
245
- // emit a vue event and prevent native event
246
- // so we don't have to write @click.native in our templates
247
- if (tag.value === 'button' && type.value !== 'submit') {
248
- event.preventDefault();
249
- emit('click', event);
250
- }
251
-
245
+ // Pass-through native click event to parent while adding ripple effect
246
+ emit('click', event);
252
247
  createRipple(event);
253
248
  };
254
249