mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
[Glitch] Profile redesign: Add Intl.Segmenter fallback
Port 9a076359b9 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { length } from 'stringz';
|
||||
|
||||
import { polymorphicForwardRef } from '@/types/polymorphic';
|
||||
|
||||
import classes from './styles.module.scss';
|
||||
@@ -14,8 +14,6 @@ interface CharacterCounterProps {
|
||||
recommended?: boolean;
|
||||
}
|
||||
|
||||
const segmenter = new Intl.Segmenter();
|
||||
|
||||
export const CharacterCounter = polymorphicForwardRef<
|
||||
'span',
|
||||
CharacterCounterProps
|
||||
@@ -31,10 +29,7 @@ export const CharacterCounter = polymorphicForwardRef<
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
const currentLength = useMemo(
|
||||
() => [...segmenter.segment(currentString)].length,
|
||||
[currentString],
|
||||
);
|
||||
const currentLength = length(currentString);
|
||||
return (
|
||||
<Component
|
||||
{...props}
|
||||
|
||||
Reference in New Issue
Block a user