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

replaceCharacterList doesn't work together with transformLabel #33

Open
juagarc4 opened this issue Sep 29, 2021 · 1 comment
Open

replaceCharacterList doesn't work together with transformLabel #33

juagarc4 opened this issue Sep 29, 2021 · 1 comment

Comments

@juagarc4
Copy link

Problem:

I'm using the component in a project in wich I need to show the titles with each Word capitalized. The titles are in german and I need therefore use the attribute "replaceCharacterList" to revert the typical transliterated characters ae => ä, ue => ü ,etc.

To capitalize each word I use "transformLabel", but then the option "replaceCharacterList" doesn't work anymore.

To Reproduce
Visited url: "http://site.url/der-einheitliche-ansprechpartner-nrw/ueber-uns"

<Breadcrumbs
useDefaultStyle={false}
containerClassName={styles.breadcrumbs}
listClassName={styles.breadcrumbs}
rootLabel='Home'
replaceCharacterList={[
{ from: '-', to: ' ' },
{ from: '_', to: ' ' },
{ from: 'ae', to: 'ä' },
{ from: 'oe', to: 'ö' },
{ from: 'ue', to: 'ü' },
]}
transformLabel={(title) => {
return title.replace(/(^.{1})|(\s+.{1})/g, (letter) => letter.toUpperCase())
}}
/>

Expected Result
Home > Der Einheitliche Ansprechpartner Nrw >Über uns

Given Result
Home > Der-Einheitliche-Ansprechpartner-Nrw > Ueber-uns

Until now I've used the follow workaround:

transformLabel={(title) => {
return title
.replaceAll('-', ' ')
.replaceAll('_', ' ')
.replaceAll('ae', 'ä')
.replaceAll('oe', 'ö')
.replaceAll('ue', 'ü')
.replace(/(^.{1})|(\s+.{1})/g, (letter) => letter.toUpperCase())
}}

Is it possible to use both "transformLabel" and "replaceCharacterList" at the same time?
It would be nice to have this useful option available.

Thanks in advance.

@jorgefelico
Copy link

jorgefelico commented Nov 30, 2021

Any updates on this? I'm also running into the same issue?
Edit: Looks like there's a PR for this: #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants