Show text and remove expand button if screen reader enabled
This commit is contained in:
@@ -53,6 +53,7 @@ import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
|||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {isAndroid} from '#/platform/detection'
|
import {isAndroid} from '#/platform/detection'
|
||||||
|
import {useA11y} from '#/state/a11y'
|
||||||
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
|
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {
|
import {
|
||||||
@@ -882,6 +883,7 @@ function ExpandableRichTextView({
|
|||||||
const [constrained, setConstrained] = useState(false)
|
const [constrained, setConstrained] = useState(false)
|
||||||
const [contentHeight, setContentHeight] = useState(0)
|
const [contentHeight, setContentHeight] = useState(0)
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const {screenReaderEnabled} = useA11y()
|
||||||
|
|
||||||
if (expanded && !hasBeenExpanded) {
|
if (expanded && !hasBeenExpanded) {
|
||||||
setHasBeenExpanded(true)
|
setHasBeenExpanded(true)
|
||||||
@@ -910,14 +912,16 @@ function ExpandableRichTextView({
|
|||||||
style={[a.text_sm, a.flex_1, a.leading_normal]}
|
style={[a.text_sm, a.flex_1, a.leading_normal]}
|
||||||
authorHandle={authorHandle}
|
authorHandle={authorHandle}
|
||||||
enableTags
|
enableTags
|
||||||
numberOfLines={expanded ? undefined : constrained ? 2 : 2}
|
numberOfLines={
|
||||||
|
expanded || screenReaderEnabled ? undefined : constrained ? 2 : 2
|
||||||
|
}
|
||||||
onTextLayout={evt => {
|
onTextLayout={evt => {
|
||||||
if (!constrained && evt.nativeEvent.lines.length > 1) {
|
if (!constrained && evt.nativeEvent.lines.length > 1) {
|
||||||
setConstrained(true)
|
setConstrained(true)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{constrained && (
|
{constrained && !screenReaderEnabled && (
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityHint={_(msg`Tap to expand or collapse post text.`)}
|
accessibilityHint={_(msg`Tap to expand or collapse post text.`)}
|
||||||
accessibilityLabel={expanded ? _(msg`Read less`) : _(msg`Read more`)}
|
accessibilityLabel={expanded ? _(msg`Read less`) : _(msg`Read more`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user