|
1 | 1 | import type {ReactNode} from 'react'; |
2 | | -import React, {useEffect, useMemo, useRef} from 'react'; |
| 2 | +import React, {useMemo} from 'react'; |
3 | 3 | import type {StyleProp, TextStyle, ViewStyle} from 'react-native'; |
4 | 4 | import {Linking, View} from 'react-native'; |
5 | | -import useDialogTitleFocus from '@hooks/useDialogTitleFocus'; |
6 | 5 | import useThemeStyles from '@hooks/useThemeStyles'; |
7 | 6 | import CONST from '@src/CONST'; |
8 | | -import {useDialogLabelActions} from './DialogLabelContext'; |
9 | 7 | import EnvironmentBadge from './EnvironmentBadge'; |
10 | 8 | import Text from './Text'; |
11 | 9 | import TextLink from './TextLink'; |
@@ -38,37 +36,6 @@ type HeaderProps = { |
38 | 36 |
|
39 | 37 | function Header({title = '', subtitle = '', textStyles = [], style, containerStyles = [], shouldShowEnvironmentBadge = false, subTitleLink = '', numberOfTitleLines = 2}: HeaderProps) { |
40 | 38 | const styles = useThemeStyles(); |
41 | | - const {isInsideDialog, pushLabel, popLabel, updateLabel} = useDialogLabelActions(); |
42 | | - const labelIdRef = useRef<number | undefined>(undefined); |
43 | | - const titleRef = useRef<React.ComponentRef<typeof Text>>(null); |
44 | | - |
45 | | - // Register/update label in dialog context (non-string titles are skipped). |
46 | | - useEffect(() => { |
47 | | - if (!isInsideDialog || typeof title !== 'string' || !title) { |
48 | | - return; |
49 | | - } |
50 | | - if (labelIdRef.current === undefined) { |
51 | | - labelIdRef.current = pushLabel(title); |
52 | | - } else { |
53 | | - updateLabel(labelIdRef.current, title); |
54 | | - } |
55 | | - }, [isInsideDialog, title, pushLabel, updateLabel]); |
56 | | - |
57 | | - // Focus title after RHP transition completes (web only, no-op on native) |
58 | | - useDialogTitleFocus(titleRef, isInsideDialog); |
59 | | - |
60 | | - // Cleanup label on unmount |
61 | | - useEffect( |
62 | | - () => () => { |
63 | | - if (labelIdRef.current === undefined) { |
64 | | - return; |
65 | | - } |
66 | | - popLabel(labelIdRef.current); |
67 | | - labelIdRef.current = undefined; |
68 | | - }, |
69 | | - [popLabel], |
70 | | - ); |
71 | | - |
72 | 39 | const renderedSubtitle = useMemo( |
73 | 40 | () => ( |
74 | 41 | <> |
@@ -109,12 +76,10 @@ function Header({title = '', subtitle = '', textStyles = [], style, containerSty |
109 | 76 | {typeof title === 'string' |
110 | 77 | ? !!title && ( |
111 | 78 | <Text |
112 | | - ref={isInsideDialog ? titleRef : undefined} |
113 | 79 | numberOfLines={numberOfTitleLines} |
114 | 80 | style={[styles.headerText, styles.textLarge, styles.lineHeightXLarge, textStyles]} |
115 | 81 | accessibilityRole={CONST.ROLE.HEADER} |
116 | 82 | accessibilityLabel={title} |
117 | | - tabIndex={isInsideDialog ? -1 : undefined} |
118 | 83 | > |
119 | 84 | {title} |
120 | 85 | </Text> |
|
0 commit comments