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
[Storybook] Space insertion in titles with diacritics characters #12534
Comments
Any chance you can contribute a fix @cesarsl? |
I will give a try as soon as I can. Thanks for taking the time to look at this issue. |
Sorry, but I can't even run storybook in developer mode. Followed all instructions in
Already tried to adjust my |
Try running:
|
Great, found the piece of code in charge of building the titles. const nonAlphanumSpace = /[a-z0-9 ]/gi;
const doubleSpace = /\s\s/gi;
const replacer = (match: string) => ` ${match} `;
const addExtraWhiteSpace = (input: string) =>
input.replace(nonAlphanumSpace, replacer).replace(doubleSpace, ' ');
const getDescription = (item: Item) => {
if (isRoot(item)) {
return item.name ? `${item.name} ⋅ Storybook` : 'Storybook';
}
if (isGroup(item)) {
return item.name ? `${item.name} ⋅ Storybook` : 'Storybook';
}
if (isStory(item)) {
const { kind, name } = item;
return kind && name ? addExtraWhiteSpace(`${kind} - ${name} ⋅ Storybook`) : 'Storybook';
}
return 'Storybook';
}; The Talking about separators: I understand that the menu building function use We could just place a better regex, but I don't think we really need. All that logic can be simplified to: const splitTitleAddExtraSpace = (input: string) => input.split('/').join(' / ');
const getDescription = (item: Item) => {
if (isRoot(item)) {
return item.name ? `${item.name} ⋅ Storybook` : 'Storybook';
}
if (isGroup(item)) {
return item.name ? `${item.name} ⋅ Storybook` : 'Storybook';
}
if (isStory(item)) {
const { kind, name } = item;
return kind && name ? splitTitleAddExtraSpace(`${kind} - ${name} ⋅ Storybook`) : 'Storybook';
}
return 'Storybook';
}; This is just a suggestion, because I don't know why these decisions were made. If someone would care to explain, I'd appreciated that. Cheers. |
@shilman Do we have to close this issue, or will it close itself? |
Will close itself once i release your fix @cesarsl |
Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.18 containing PR #12583 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Describe the bug
When using the characters with diacritics
(' " ` ´ ^ ¸ ~)
, Storybook inserts white space characters between them and the ones before and after.To Reproduce
Steps to reproduce the behavior:
<Meta title="" />
with a word and some diacritic character attached to it. Example:São
<title>
tag inside the page's htmlExpected behavior
Would expect no white spaces between those characters
Screenshots
Code snippets
System:
Additional context
Reproduced in Linux, macOS and Windows
The text was updated successfully, but these errors were encountered: