Skip to content

Commit 5800d61

Browse files
committed
Add fomantic-dropdown webcomponent
Using a vanilla web component add the correct event listener for handling dropdowns.
1 parent 2aa59ba commit 5800d61

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

templates/repo/issue/view_content/context_menu.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="item action ui dropdown jump pointing top right context-dropdown">
1+
<fomantic-dropdown class="item action ui dropdown jump pointing top right context-dropdown">
22
<a class="context-menu muted">
33
{{svg "octicon-kebab-horizontal"}}
44
</a>
@@ -41,4 +41,4 @@
4141
{{end}}
4242
{{end}}
4343
</div>
44-
</div>
44+
</fomantic-dropdown>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Dropdown web component.
3+
*
4+
* This component wraps a Fomantic UI dropdown, allowing you to apply the same
5+
* classes and attributes as you would with a standard Fomantic dropdown.
6+
*
7+
* It ensures automatic initialization when connected to the DOM, which is useful
8+
* for dynamically added elements, eliminating the need for manual initialization.
9+
*/
10+
class FomanticDropdown extends HTMLElement {
11+
connectedCallback() {
12+
if (window.jQuery) {
13+
window.$(this).dropdown();
14+
}
15+
// note: if jquery is not defined then this component was part of the initial page load and
16+
// will be initialized by the fomantic-ui js
17+
}
18+
}
19+
20+
customElements.define('fomantic-dropdown', FomanticDropdown);

web_src/js/webcomponents/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ import '@github/relative-time-element';
33
import './origin-url.ts';
44
import './overflow-menu.ts';
55
import './absolute-date.ts';
6+
import './fomantic-dropdown.ts';

0 commit comments

Comments
 (0)