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

Add stopPropagation to the Dropdown class #6613

Open
wants to merge 2 commits into
base: v1-dev
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions jade/page-contents/dropdown_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ <h3 class="header">Options</h3>
<td>null</td>
<td>Function called when dropdown finishes exiting.</td>
</tr>
<tr>
<td>stopPropagation</td>
<td>Boolean</td>
<td>false</td>
<td>Stop the propagation of a click event for the dropdown trigger</td>
</tr>
</tbody>
</table>
</div>
Expand Down
9 changes: 8 additions & 1 deletion js/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
onOpenEnd: null,
onCloseStart: null,
onCloseEnd: null,
onItemClick: null
onItemClick: null,
stopPropagation: false
};

/**
Expand Down Expand Up @@ -48,6 +49,7 @@
* @prop {Function} onOpenEnd - Function called when dropdown finishes opening
* @prop {Function} onCloseStart - Function called when dropdown starts closing
* @prop {Function} onCloseEnd - Function called when dropdown finishes closing
* @prop {Boolean} [stopPropagation=false] - Constrain width to width of the button
*/
this.options = $.extend({}, Dropdown.defaults, options);

Expand Down Expand Up @@ -170,6 +172,11 @@

_handleClick(e) {
e.preventDefault();

if (stopPropagation) {
e.stopPropagation();
}

this.open();
}

Expand Down