Skip to content

Autofocus flux:editor in modal #1483

Discussion options

You must be logged in to vote

@LuciusAB Another method would be to use Alpine's x-intersect (https://alpinejs.dev/plugins/intersect) to trigger a piece of code when the modal becomes visible (a nod to @ju5t for the great idea! see: #760 (comment)) - I think I prefer this method for it's cleaner/simpler code:

<?php

use Flux\Flux;
use Livewire\Volt\Component;

new class extends Component
{
    public string $content = 'Testing...';
};
?>

<div>
    <flux:modal.trigger name="edit-profile">
        <flux:button>Edit profile</flux:button>
    </flux:modal.trigger>

    <flux:modal name="edit-profile" class="md:w-96">
        <div x-intersect="document.getElementById('my-editor').editor.commands.focus('start')">
            <

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@LuciusAB
Comment options

@jeffchown
Comment options

@jeffchown
Comment options

@jeffchown
Comment options

Answer selected by LuciusAB
@LuciusAB
Comment options

@jeffchown
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants