Skip to content

Commit

Permalink
Merge pull request #147 from awcodes/fix/unset-link-from-modal
Browse files Browse the repository at this point in the history
Fix: remove link from modal action
  • Loading branch information
awcodes authored Aug 6, 2023
2 parents 2fe23e5 + f4a8fbf commit 30439de
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/Actions/LinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,22 @@ protected function setUp(): void
);

$component->state($component->getState());
})->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('remove_link', [])
->color('danger')
->extraAttributes([
'x-on:click' => new HtmlString('$dispatch(\'unset-link\'); close()'),
'style' => 'margin-inline-start: auto;'
])
]);
})->extraModalFooterActions(function (Action $action): array {

if ($action->getArguments()['href'] !== '') {
return [
$action->makeModalSubmitAction('remove_link', [])
->color('danger')
->extraAttributes(function () use ($action) {
return [
'x-on:click' => new HtmlString("\$dispatch('unset-link', {'statePath': '{$action->getComponent()->getStatePath()}'}); close()"),
'style' => 'margin-inline-start: auto;'
];
})
];
}

return [];
});
}
}

0 comments on commit 30439de

Please sign in to comment.