Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
feat(select): fires 'dqpl:select:change' when selection is made (#111)
Browse files Browse the repository at this point in the history
* feat(select): fires 'dqpl:select:change' when selection is made

* bubbles
  • Loading branch information
schne324 authored and AutoSponge committed Apr 30, 2019
1 parent 70d18dd commit dc78d68
Show file tree
Hide file tree
Showing 3 changed files with 991 additions and 994 deletions.
9 changes: 9 additions & 0 deletions lib/components/selects/select.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import Classlist from 'classlist';
import CustomEvent from 'custom-event';

/**
* Cleans up previously selected / sets new selection
Expand All @@ -17,6 +18,14 @@ module.exports = (listboxButton, listbox, noHide) => {
if (active) {
active.setAttribute('aria-selected', 'true');
Classlist(active).add('dqpl-option-selected');
// fire a custom change event
const onChange = new CustomEvent('dqpl:select:change', {
bubbles: true,
detail: {
value: active.innerHTML
}
});
listboxButton.dispatchEvent(onChange);
}

if (!noHide) {
Expand Down
Loading

0 comments on commit dc78d68

Please sign in to comment.