Skip to content

Commit b08fb11

Browse files
committed
fix(d-dropdown): hide dropdown when link is clicked
1 parent 0880138 commit b08fb11

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
55
### 1.0.5 - (2018-10-30)
66

77
* fix(d-link): exact/active classes not properly applied #10
8+
* fix(d-dropdown): hide dropdown when link is clicked
89

910
### 1.0.4 - (2018-10-15)
1011

src/components/dropdown/Dropdown.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<script>
6363
import Popper from 'popper.js'
6464
import { guid, closest } from '../../utils'
65-
import { THEMECOLORS, DROPDOWN_EVENTS, KEYCODES } from '../../utils/constants'
65+
import { THEMECOLORS, DROPDOWN_EVENTS, KEYCODES, LINK_EVENTS } from '../../utils/constants'
6666
import { CancelableEvent } from '../../utils/events'
6767
import { mixin as clickAwayMixin } from 'vue-clickaway';
6868
import rootListenerMixin from '../../mixins/root-listener.mixin'
@@ -421,6 +421,8 @@ export default {
421421
this.visible = false
422422
}
423423
})
424+
425+
this.listenOnRoot(LINK_EVENTS.CLICKED, this.away)
424426
},
425427
deactivated() {
426428
this.visible = false

src/components/link/Link.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111
disabled ? 'disabled' : ''
1212
]"
1313
:aria-disabled="computedAriaDisabled"
14-
@click="handleClick">
14+
@click.native="handleClick">
1515
<slot>Link</slot>
1616
</component>
1717
</template>
1818

1919
<script>
20+
import { LINK_EVENTS } from '../../utils/constants';
21+
import rootListenerMixin from '../../mixins/root-listener.mixin'
22+
2023
export default {
2124
name: 'd-link',
25+
mixins: [ rootListenerMixin ],
2226
props: {
2327
/**
2428
* The link href.
@@ -140,6 +144,8 @@ export default {
140144
} else {
141145
this.$emit('click', event);
142146
}
147+
148+
this.emitOnRoot(LINK_EVENTS.CLICKED, event);
143149
}
144150
145151
if ((!isRouterLink && this.computedHref === '#') || this.disabled) {

src/utils/constants.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ export const DROPDOWN_EVENTS = {
4444
HIDDEN: 'dropdown-hidden'
4545
}
4646

47+
// Link Events
48+
export const LINK_EVENTS = {
49+
CLICKED: 'link-clicked'
50+
}
51+
4752
// All events
4853
export const EVENTS = {
4954
MODAL: MODAL_EVENTS,
5055
ALERT: ALERT_EVENTS,
51-
DROPDOWN: DROPDOWN_EVENTS
56+
DROPDOWN: DROPDOWN_EVENTS,
57+
LINK: LINK_EVENTS
5258
}
5359

5460
/**

0 commit comments

Comments
 (0)