Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the tab title is in Chinese, the Form Tab is not separated correctly. #14080

Open
cityisempty opened this issue Aug 28, 2024 · 1 comment
Labels
Milestone

Comments

@cityisempty
Copy link

cityisempty commented Aug 28, 2024

Package

filament/filament

Package Version

V3.2.0

Laravel Version

v11

Livewire Version

No response

PHP Version

PHP 8.3

Problem description

When I have two tabs in the form, if both tabs have Chinese titles, then their contents are merged into one, and both tabs are in a selected state.
截屏2024-08-28 22 12 25
截屏2024-08-28 22 12 58

Expected behavior

When using tabs, Chinese characters should be handled correctly.

Steps to reproduce

Tabs\Tab::make(__('基本信息'))->schema([
TextInput::make('title')
                            ->label(__('Post Title'))
                            ->required()
                            ->maxLength(255)
                            ->live(onBlur: true)]),
Tabs\Tab::make(__('(E)扩展信息'))->schema([
                        Placeholder::make(__('扩展信息')),
    
                        Hidden::make('user_id')
                            ->default(auth()->user()->id)
                            ->required(),
    
                        Hidden::make('post_type')
                            ->default('post')
                            ->required()])

When I use the above code, the error occurs. If I change it to the following code, the result is correct.

Tabs\Tab::make(__('Title '))->schema([
TextInput::make('title')
                            ->label(__('Post Title'))
                            ->required()
                            ->maxLength(255)
                            ->live(onBlur: true)]),
Tabs\Tab::make(__('Other Info '))->schema([
                        Placeholder::make(__('扩展信息')),
    
                        Hidden::make('user_id')
                            ->default(auth()->user()->id)
                            ->required(),
    
                        Hidden::make('post_type')
                            ->default('post')
                            ->required()])

Reproduction repository (issue will be closed if this is not valid)

https://github.com/cityisempty/filament-issue

Relevant log output

No response

Donate 💰 to fund this issue

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar
@zxc88645
Copy link

zxc88645 commented Sep 5, 2024

The issue comes from
forms/src/Components/Tabs/Tab.php
infolists/src/Components/Tabs/Tab.php

    final public function __construct(string $label)
    {
        $this->label($label);
        $this->id(Str::slug($label));
    }
Str::slug($title, $separator = '-', $language = 'en', $dictionary = ['@' => 'at'])

The language parameter defaults to en, and when encountering Chinese characters, it results in an empty string.

I recommend modifying it to:

$this->id(Str::slug(Str::transliterate($label, strict: true)));

@zepfietje zepfietje added this to the v3 milestone Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants