mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
677b4f2e79
* Use dropdown component in sites page * Add x- attributes to globals * Update tests * Prevent default on click * Fix compile warning * Add conditional rendering back in * Remove $id magic
21 lines
330 B
JavaScript
21 lines
330 B
JavaScript
// From https://alpinejs.dev/component/dropdown
|
|
|
|
export default () => ({
|
|
open: false,
|
|
toggle() {
|
|
if (this.open) {
|
|
return this.close()
|
|
}
|
|
|
|
this.$refs.button.focus()
|
|
this.open = true
|
|
},
|
|
|
|
close(focusAfter) {
|
|
if (! this.open) return
|
|
|
|
this.open = false
|
|
focusAfter && focusAfter.focus()
|
|
},
|
|
})
|