getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

[v4] Panel unaware of custom slug rules #5929

Closed nilshoerrmann closed 11 months ago

nilshoerrmann commented 1 year ago

Description

Kirby allows for the creation of custom slugs rules by setting the static property of the Str class:

Str::$defaults['slug']['allowed'] = 'my rules here';

These settings are not passed to the create and changeTitle dialogs.

Expected behavior
The panel should respect the general slug settings.

To reproduce

Set custom rules in a page model or the config, create a page or update a title. The slug will always be created based on the default settings.

Additional context
Passing 'allow' => Str::$defaults['slug']['allowed'] to the slug field will fix this issue, see here:

nilshoerrmann commented 1 year ago

PS: The same issue exists for custom separator settings in Str::$defaults['slug']['separator'].

distantnative commented 1 year ago

The fix is not quite as easy, as the JS helper will not use the passed allowed characters, but only add them to the default a-z0-9, so that wouldn't allow overwriting default allowed with a. more restricting set.

nilshoerrmann commented 1 year ago

Wouldn't changing https://github.com/getkirby/kirby/blob/v4/develop/panel/src/helpers/string.js#L173C2-L173C30 to allowed = allowed ? allowed : "a-z0-9"; solve this issue?

nilshoerrmann commented 1 year ago

I understand that this would not be backwards compatible but I'd technically consider this a bug because the panel behaves differently compared to the backend (and the backend actually allows for complete customization).