Skip to content

Commit

Permalink
add wire:key (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev authored Sep 28, 2023
1 parent 12584c8 commit b08c753
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions resources/views/components/editable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
$resolveContent = function (string $currentTable, string $field, \Illuminate\Database\Eloquent\Model|\stdClass $row): ?string {
$currentField = $field;
$replace = fn($content) => preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
/** @codeCoverageIgnore */
if (str_contains($currentField, '.')) {
$data = \Illuminate\Support\Str::of($field)->explode('.');
$table = $data->get(0);
$field = $data->get(1);
if ($table === $currentTable) {
return $replace($row->{$field});
}
return $replace($row->{$table}->{$field});
}
return $replace($row->{$field});
};
$fallback = html_entity_decode(strval(data_get($editable, 'fallback')), ENT_QUOTES, 'utf-8');
$value = html_entity_decode(strval($resolveContent($currentTable, $field, $row)), ENT_QUOTES, 'utf-8');
$content = !empty($value) || $value == '0' ? $value : $fallback;
$params = [
'theme' => $theme->name,
'tableName' => $tableName,
Expand All @@ -45,6 +45,7 @@
];
@endphp
<div
wire:key="editable-{{ uniqid() }}"
x-cloak
x-data="pgEditable(@js($params))"
style="width: 100% !important; height: 100% !important;"
Expand Down

0 comments on commit b08c753

Please sign in to comment.