mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-07 05:39:44 -06:00
24 lines
531 B
JavaScript
24 lines
531 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["input", "button"]
|
|
|
|
select(event) {
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
|
|
const button = event.currentTarget
|
|
const icon = button.dataset.icon
|
|
|
|
if (this.hasInputTarget && icon) {
|
|
this.inputTarget.value = icon
|
|
|
|
// Close the dropdown by removing focus
|
|
const activeElement = document.activeElement
|
|
if (activeElement) {
|
|
activeElement.blur()
|
|
}
|
|
}
|
|
}
|
|
}
|