Fix post numbers being clipped in some cases (#11413)

This commit is contained in:
DS Boyce
2026-08-06 16:34:49 -07:00
committed by GitHub
parent 1c349ad7da
commit 1e6725c0a1
5 changed files with 49 additions and 19 deletions
@@ -5,13 +5,22 @@ import {Trans, useLingui} from '@lingui/react/macro'
import {atoms as a, native, platform, useTheme} from '#/alf'
import {useAnalytics} from '#/analytics'
export function hasThreadItemPostNumber(
/**
* How far the inline badge is nudged below the text baseline to optically
* center it. The containing `RichText` must reserve matching room via
* `suffixOffset`, or iOS clips the overflow.
*/
export const POST_NUMBER_INLINE_OFFSET = 6
export function useHasThreadItemPostNumber(
value: AppBskyUnspeccedDefs.ThreadItemPost,
) {
const ax = useAnalytics()
const index = value.opThreadPostIndex
const count = value.opThreadPostCount
return (
ax.features.enabled(ax.features.CanonicalPostNumberingEnable) &&
index !== undefined &&
count !== undefined &&
index >= 1 &&
@@ -27,17 +36,13 @@ export function ThreadItemPostNumber({
value: AppBskyUnspeccedDefs.ThreadItemPost
inline?: boolean
}) {
const ax = useAnalytics()
const t = useTheme()
const {t: l} = useLingui()
const shouldRender = useHasThreadItemPostNumber(value)
const index = value.opThreadPostIndex
const count = value.opThreadPostCount
const isEnabled = ax.features.enabled(
ax.features.CanonicalPostNumberingEnable,
)
if (!isEnabled || !hasThreadItemPostNumber(value)) {
if (!shouldRender) {
return null
}
@@ -54,7 +59,7 @@ export function ThreadItemPostNumber({
},
inline
? platform({
native: {transform: [{translateY: 6}]},
native: {transform: [{translateY: POST_NUMBER_INLINE_OFFSET}]},
web: {top: -2},
})
: {top: -2},