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

Don't split words on non-breaking space char #460

Merged
merged 1 commit into from
Jul 9, 2019

Conversation

robsco-git
Copy link
Contributor

@robsco-git robsco-git commented May 8, 2019

🚀 Enhancements

  • Don't split strings rendered by <Text /> when encountering a set of non-breaking space characters. Currency strings output by Number.toLocaleString, for example, can contain non-breaking space characters. The emitted SVG tspan elements (words) should not be split by these characters.

Currency strings output by Number.toLocaleString, for example, can contain non-breaking space characters. The emitted SVG tspan elements should not be split by these characters.
Copy link
Member

@hshoff hshoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks for the contribution!

Confirmed the fix

const number = 123456.789;
const before = /\s+/;
const after = /(?:(?!\u00A0+)\s+)/;
const string = number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' });
console.log(`price ${string}`.split(before));
// => ["price", "123.456,79", "€"]
console.log(`price ${string}`.split(after));
// => ["price", "123.456,79 €"]

I'm going to mark this as a breaking change in the changelog as it does alter the behavior of <Text />

@hshoff hshoff added this to the v0.0.190 milestone Jul 9, 2019
@hshoff hshoff merged commit 9c028eb into airbnb:master Jul 9, 2019
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

Successfully merging this pull request may close these issues.

2 participants