From 2a3233f2b0cac0428149f67c13a61093d0d79737 Mon Sep 17 00:00:00 2001 From: Dima Udod Date: Tue, 7 May 2024 14:11:28 +0300 Subject: [PATCH 1/5] Fix for bug #8870 --- .../resources/views/components/button/index.blade.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/support/resources/views/components/button/index.blade.php b/packages/support/resources/views/components/button/index.blade.php index 8459983aae7..59b98a50d34 100644 --- a/packages/support/resources/views/components/button/index.blade.php +++ b/packages/support/resources/views/components/button/index.blade.php @@ -140,6 +140,10 @@ } $hasTooltip = filled($tooltip); + + if ($keyBindings) { + $keyBindingsAsString = collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.'); + } @endphp @if ($labeledFrom) @@ -183,7 +187,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + id=@js($keyBindingsAsString) + x-mousetrap.global.{{ $keyBindingsAsString }}="document.getElementById(@js($keyBindingsAsString)).click()" @endif @if ($hasTooltip) x-tooltip="{ From 4059c97467f437aa020fef69cc97cfb66069115d Mon Sep 17 00:00:00 2001 From: Dima Udod Date: Tue, 7 May 2024 14:17:10 +0300 Subject: [PATCH 2/5] Remove unnecessary @js block --- .../support/resources/views/components/button/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/support/resources/views/components/button/index.blade.php b/packages/support/resources/views/components/button/index.blade.php index 59b98a50d34..d24e5981b5a 100644 --- a/packages/support/resources/views/components/button/index.blade.php +++ b/packages/support/resources/views/components/button/index.blade.php @@ -187,7 +187,7 @@ x-data="{}" @endif @if ($keyBindings) - id=@js($keyBindingsAsString) + id="{{ $keyBindingsAsString }}" x-mousetrap.global.{{ $keyBindingsAsString }}="document.getElementById(@js($keyBindingsAsString)).click()" @endif @if ($hasTooltip) From edb4251bf52ec7c7eff34bcd2cfad164bcbf4085 Mon Sep 17 00:00:00 2001 From: Dima Udod Date: Thu, 9 May 2024 08:09:37 +0300 Subject: [PATCH 3/5] User livewire insted of self generated id --- .../resources/views/components/button/index.blade.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/support/resources/views/components/button/index.blade.php b/packages/support/resources/views/components/button/index.blade.php index d24e5981b5a..8c5f2f5196b 100644 --- a/packages/support/resources/views/components/button/index.blade.php +++ b/packages/support/resources/views/components/button/index.blade.php @@ -140,10 +140,6 @@ } $hasTooltip = filled($tooltip); - - if ($keyBindings) { - $keyBindingsAsString = collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.'); - } @endphp @if ($labeledFrom) @@ -187,8 +183,8 @@ x-data="{}" @endif @if ($keyBindings) - id="{{ $keyBindingsAsString }}" - x-mousetrap.global.{{ $keyBindingsAsString }}="document.getElementById(@js($keyBindingsAsString)).click()" + :id="$id('key-binding')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ From 2efc5d4209b679b248964c16530cd7e959707e3d Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 9 May 2024 09:13:53 +0100 Subject: [PATCH 4/5] Update index.blade.php --- .../support/resources/views/components/button/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/support/resources/views/components/button/index.blade.php b/packages/support/resources/views/components/button/index.blade.php index 8c5f2f5196b..00f0a5dbbf2 100644 --- a/packages/support/resources/views/components/button/index.blade.php +++ b/packages/support/resources/views/components/button/index.blade.php @@ -183,7 +183,7 @@ x-data="{}" @endif @if ($keyBindings) - :id="$id('key-binding')" + :id="$id('key-bindings')" x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) From 119f08eaed94b093d16c126f0639a4af66713118 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 9 May 2024 09:17:00 +0100 Subject: [PATCH 5/5] add other usages --- .../support/resources/views/components/badge.blade.php | 3 ++- .../resources/views/components/button/index.blade.php | 2 +- .../views/components/dropdown/list/item.blade.php | 9 ++++++--- .../resources/views/components/icon-button.blade.php | 6 ++++-- .../support/resources/views/components/link.blade.php | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/support/resources/views/components/badge.blade.php b/packages/support/resources/views/components/badge.blade.php index 1f22943f7ac..bc6bcc8e279 100644 --- a/packages/support/resources/views/components/badge.blade.php +++ b/packages/support/resources/views/components/badge.blade.php @@ -81,7 +81,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ diff --git a/packages/support/resources/views/components/button/index.blade.php b/packages/support/resources/views/components/button/index.blade.php index 00f0a5dbbf2..9388814b55f 100644 --- a/packages/support/resources/views/components/button/index.blade.php +++ b/packages/support/resources/views/components/button/index.blade.php @@ -183,7 +183,7 @@ x-data="{}" @endif @if ($keyBindings) - :id="$id('key-bindings')" + x-bind:id="$id('key-bindings')" x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) diff --git a/packages/support/resources/views/components/dropdown/list/item.blade.php b/packages/support/resources/views/components/dropdown/list/item.blade.php index 735b1eb24bb..99b9cf73f39 100644 --- a/packages/support/resources/views/components/dropdown/list/item.blade.php +++ b/packages/support/resources/views/components/dropdown/list/item.blade.php @@ -102,7 +102,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ @@ -182,7 +183,8 @@ class="{{ $imageClasses }}" x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ @@ -233,7 +235,8 @@ class="{{ $imageClasses }}" x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ diff --git a/packages/support/resources/views/components/icon-button.blade.php b/packages/support/resources/views/components/icon-button.blade.php index b35b5c48fa2..5256c18baf8 100644 --- a/packages/support/resources/views/components/icon-button.blade.php +++ b/packages/support/resources/views/components/icon-button.blade.php @@ -128,7 +128,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ @@ -197,7 +198,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ diff --git a/packages/support/resources/views/components/link.blade.php b/packages/support/resources/views/components/link.blade.php index 53b8a9d0dda..73b93a33584 100644 --- a/packages/support/resources/views/components/link.blade.php +++ b/packages/support/resources/views/components/link.blade.php @@ -134,7 +134,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{ @@ -181,7 +182,8 @@ x-data="{}" @endif @if ($keyBindings) - x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} + x-bind:id="$id('key-bindings')" + x-mousetrap.global.{{ collect($keyBindings)->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }}="document.getElementById($el.id).click()" @endif @if ($hasTooltip) x-tooltip="{