Textarea autoSize after save or error

I'm trying to make my textarea autosize. Everything works fine upon rendering, but if I save the form or encounter an error, the textarea does not autosize and shrinks to 2 rows. Basic form :
Textarea::make('textarea_input_test')
->autosize(),
Textarea::make('textarea_input_test')
->autosize(),
I see some other declared issue but not work.
Solution:
There’s an open PR that will fix this when it’s merged.
Jump to solution
16 Replies
Solution
awcodes
awcodes4mo ago
There’s an open PR that will fix this when it’s merged.
yebor974
yebor9744mo ago
I missed the PR, thanks for the info!
David | Fortune Validator
did this get merged. I am having this problem still and I'm on the latest release. When I use $set in the action of a HintAction on the orignal form inside a orignal moda. The textarea gets reset ah I think not. fairly new to working on githib. I see it was merged yesterday but the latest filament release was last week. hmmm @awcodes I see the update was just released. Testing my end doesnt seem to have fixed our issue. We have a hint action that will get an address and then $set is back into the textfield. If the address has more lines than the original textfield size it doesnt autosize. Was this the original issue?
awcodes
awcodes3mo ago
make sure you run artisan filament:upgrade. zep verified that the fix works.
David | Fortune Validator
I'll run it again I have that on my script though I'll see if I can capture a video of it oh dear lord. I had removed the ->autofocus() before I tested the release sorry about that Hmm half fixed from what I can tell (first option doesnt work but second does). It seems if a modal form is involved in the hint action it didnt like it: didnt work:
\Filament\Forms\Components\Actions\Action::make('collect_supplier_address_modal')
->label('Supplier')
->modalSubmitActionLabel('Add Address')
->icon('heroicon-o-magnifying-glass')
->form(fn(Get $get)=>self::searchSupplierActionSchema($get))
->action(fn (array $data, Set $set) => $set('collectFrom', Supplier::find($data['supplier_id'])->address ?? null)),


\Filament\Forms\Components\Actions\Action::make('collect_supplier_address_modal')
->label('Supplier')
->modalSubmitActionLabel('Add Address')
->icon('heroicon-o-magnifying-glass')
->form(fn(Get $get)=>self::searchSupplierActionSchema($get))
->action(fn (array $data, Set $set) => $set('collectFrom', Supplier::find($data['supplier_id'])->address ?? null)),


Worked:
\Filament\Forms\Components\Actions\Action::make('collect_supplier_address_modal2')
->label('Supplier2')
->modalSubmitActionLabel('Add Address')
->icon('heroicon-o-magnifying-glass')
->action(fn (array $data, Set $set) => $set('collectFrom',"test\ntest\ns\n\n\n\ntest")),
\Filament\Forms\Components\Actions\Action::make('collect_supplier_address_modal2')
->label('Supplier2')
->modalSubmitActionLabel('Add Address')
->icon('heroicon-o-magnifying-glass')
->action(fn (array $data, Set $set) => $set('collectFrom',"test\ntest\ns\n\n\n\ntest")),
awcodes
awcodes3mo ago
Action modals work in the demo
awcodes
awcodes3mo ago
you are welcome to open an issue if you can give us a minimum reproduction repo. 🙂
David | Fortune Validator
I could be wrong but I don't see in that clip the value from the hint action being passed back down to the Create Post form textfield? I have a hint action that gets a supplier. The action() then gets the address of said supplier and $set it into the parent form it works if no form() on the modal and you only run login in action() trying to debug it seems rather odd.
awcodes
awcodes3mo ago
Not sure then sorry. I'd have to see it. if you think its a bug please submit an issue for it on GitHub with a reporoduction repo. 🙂
David | Fortune Validator
okay, so its 100% not my code. doesnt work:
->form(fn(Get $get)=>[TextInput::make('test')])
->action(fn (array $data, Set $set) => $set('collectFrom', Client::find(1072)->address ?? null)),
->form(fn(Get $get)=>[TextInput::make('test')])
->action(fn (array $data, Set $set) => $set('collectFrom', Client::find(1072)->address ?? null)),
works:
->form(fn(Get $get)=>[])
->action(fn (array $data, Set $set) => $set('collectFrom', Client::find(1072)->address ?? null)),
->form(fn(Get $get)=>[])
->action(fn (array $data, Set $set) => $set('collectFrom', Client::find(1072)->address ?? null)),
awcodes
awcodes3mo ago
what does this have to do with the textarea autosize?
David | Fortune Validator
Textarea::make('collectFrom')->autosize()->rows(5)->hintActions(
[
\Filament\Forms\Components\Actions\Action::make('collect_client_address_modal')
->label('Client')
->icon('heroicon-o-magnifying-glass')
->modalSubmitActionLabel('Add Address')
->form(fn(Get $get)=>self::searchClientActionSchema($get))
->action(fn (array $data, Set $set) => $set('collectFrom', Client::find($data['client_id'])->address ?? null)),
]
),
Textarea::make('collectFrom')->autosize()->rows(5)->hintActions(
[
\Filament\Forms\Components\Actions\Action::make('collect_client_address_modal')
->label('Client')
->icon('heroicon-o-magnifying-glass')
->modalSubmitActionLabel('Add Address')
->form(fn(Get $get)=>self::searchClientActionSchema($get))
->action(fn (array $data, Set $set) => $set('collectFrom', Client::find($data['client_id'])->address ?? null)),
]
),
Sorry here is the full code. Textarea has a hintAction(). The hintaction is a modal form with a Select to get a Supplier. The action() on the hintaction $set the address back down to the Textarea the textarea does not update its size however, if I dont have a modal popup form on the hintaction and only apply some manual logic in the action() then it will work. so it seems if a second modal is introduced that upon Submit it should $set the parent Textfield, it fails
awcodes
awcodes3mo ago
ok. please submit an issue on GitHub. Can't do anything about it on here and I"m not seeing anything weird in your code.
David | Fortune Validator
Will do ty
David | Fortune Validator
https://github.com/filamentphp/filament/issues/13879 like but really sorry I dont have the time to get a production repo in place right now. It should be very easy to replicate from the preivous PRs repo ?
GitHub
Autosize not adjusting after its value is $set from a hintAction · ...
Package filament/filament Package Version v3.2.98 Laravel Version v11.19 Livewire Version v3 PHP Version PHP 8.3 Problem description Autosize is not adjusting its size after a hintAction WITH a for...
David | Fortune Validator
added a comment to PR: https://github.com/filamentphp/filament/pull/13748#issuecomment-2278052939 maybe that better explains 🙂
GitHub
Persist Textarea autosize by awcodes · Pull Request #13748 · filame...
Description Resolves #13722. Prevents textarea autosize from being reset during livewire requests. Visual changes


Screen.Recording.2024-07-30.at.1.07.45.PM.mov



...
Want results from more Discord servers?
Add your server