Skip to content
This repository was archived by the owner on Apr 21, 2022. It is now read-only.

Commit ee8df12

Browse files
committed
Initialize picker by means of a Promise to make it work a bit more reliable
1 parent f9de8d7 commit ee8df12

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

resources/views/colorpicker.blade.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,26 @@
1212
x-data="{
1313
color: $wire.entangle('{{ $getStatePath() }}'),
1414
picker: undefined,
15+
get scriptLoaded() {
16+
return Promise.race([
17+
new Promise(resolve => {
18+
window.addEventListener('filament-color-picker:init', resolve, {
19+
once: true,
20+
});
21+
}),
22+
new Promise(resolve => {
23+
const intervalId = window.setInterval(() => {
24+
if (window.FilamentColorPicker) {
25+
window.clearInterval(intervalId);
26+
27+
resolve();
28+
}
29+
}, 250);
30+
}),
31+
]);
32+
},
1533
init() {
16-
$nextTick(() => {
34+
this.scriptLoaded.then(() => {
1735
this.picker = window.FilamentColorPicker.make($wire, {
1836
parent: $refs.colorPicker,
1937
...@js($getPickerOptions()),

0 commit comments

Comments
 (0)