Send icon urls with buttons and resolve duplicate bridge items on the board perma since there are duplicate hidden elements

This commit is contained in:
Jay Ohms
2026-01-08 22:01:08 -05:00
parent b9dcc3c08f
commit 2b0c4b4c69
7 changed files with 26 additions and 49 deletions
@@ -5,26 +5,16 @@ export default class extends BridgeComponent {
static component = "buttons"
static targets = [ "button" ]
connect() {
super.connect()
if (this.hasButtonTarget) {
this.notifyBridgeOfConnect()
}
}
disconnect() {
super.disconnect()
if (this.hasButtonTarget) {
this.notifyBridgeOfDisconnect()
}
buttonTargetConnected(element) {
this.notifyBridgeOfConnect()
}
notifyBridgeOfConnect() {
const buttons = this.buttonTargets.map((target, index) => {
const element = new BridgeElement(target)
return { ...element.getButton(), index }
const buttons = this.buttonTargets
.filter(target => !target.closest("[data-bridge-disabled]"))
.map((target, index) => {
const element = new BridgeElement(target)
return { ...element.getButton(), index }
})
this.send("connect", { buttons }, message => {
@@ -32,10 +22,6 @@ export default class extends BridgeComponent {
})
}
notifyBridgeOfDisconnect() {
this.send("disconnect")
}
clickButton(message) {
const selectedIndex = message.data.selectedIndex
this.buttonTargets[selectedIndex].click()
@@ -5,37 +5,23 @@ export default class extends BridgeComponent {
static component = "overflow-menu"
static targets = [ "item" ]
connect() {
super.connect()
if (this.hasItemTarget) {
this.notifyBridgeOfConnect()
}
}
disconnect() {
super.disconnect()
if (this.hasItemTarget) {
this.notifyBridgeOfDisconnect()
}
itemTargetConnected() {
this.notifyBridgeOfConnect()
}
notifyBridgeOfConnect() {
const items = this.itemTargets.map((target, index) => {
const element = new BridgeElement(target)
return { title: element.title, index }
})
const items = this.itemTargets
.filter(target => !target.closest("[data-bridge-disabled]"))
.map((target, index) => {
const element = new BridgeElement(target)
return { title: element.title, index }
})
this.send("connect", { items }, message => {
this.clickItem(message)
})
}
notifyBridgeOfDisconnect() {
this.send("disconnect")
}
clickItem(message) {
const selectedIndex = message.data.selectedIndex
this.itemTargets[selectedIndex].click()