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

Removes an unneeded handler for input blur in Leo chat on Android (uplift to 1.70.x) #25497

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ type Props = Pick<AIChatContext,

interface InputBoxProps {
context: Props
onFocusInputMobile: () => void
onBlurInputMobile: () => void
onFocusInputMobile?: () => unknown
}

function InputBox(props: InputBoxProps) {
Expand Down Expand Up @@ -71,15 +70,9 @@ function InputBox(props: InputBoxProps) {
let handleFocusMobile
if (props.context.isMobile) {
handleFocusMobile = (event: React.FormEvent<HTMLTextAreaElement>) => {
props.onFocusInputMobile()
}
}

// We don't want to handle that event on desktop
let handleBlurMobile
if (props.context.isMobile) {
handleBlurMobile = (event: React.FormEvent<HTMLTextAreaElement>) => {
props.onBlurInputMobile()
if (props.onFocusInputMobile) {
props.onFocusInputMobile()
}
}
}

Expand Down Expand Up @@ -110,7 +103,6 @@ function InputBox(props: InputBoxProps) {
onChange={onInputChange}
onKeyDown={handleOnKeyDown}
onFocus={handleFocusMobile}
onBlur={handleBlurMobile}
value={props.context.inputText}
autoFocus
rows={1}
Expand Down
14 changes: 1 addition & 13 deletions components/ai_chat/resources/page/components/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ function Main() {
}
}

const inputFocused = React.useRef(false)
const viewPortWithoutKeyboard = React.useRef(0)
const keyboardSize = React.useRef(0)

React.useEffect(() => {
const handler = () => {
if (!context.isMobile || !inputFocused.current ||
!window.visualViewport) {
if (!context.isMobile || !window.visualViewport) {
return
}
const viewPortWithKeyboard = window.visualViewport.height
Expand Down Expand Up @@ -149,20 +147,11 @@ function Main() {
}, [])

const handleOnFocusInputMobile = () => {
inputFocused.current = true
if (window.visualViewport != null) {
viewPortWithoutKeyboard.current = window.visualViewport.height
}
}

const handleOnBlurInputMobile = () => {
const mountPoint = document.getElementById('mountPoint')
if (mountPoint && mountPoint?.style.height !== '100%') {
inputFocused.current = false
mountPoint.style.height = '100%'
}
}

return (
<main className={styles.main}>
{context.showAgreementModal && <PrivacyMessage />}
Expand Down Expand Up @@ -278,7 +267,6 @@ function Main() {
<InputBox
context={context}
onFocusInputMobile={handleOnFocusInputMobile}
onBlurInputMobile={handleOnBlurInputMobile}
/>
</ToolsButtonMenu>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export default function BeginGeneration() {
shouldDisableUserInput: context.isGenerating,
isMobile: false,
hasAcceptedAgreement: true
}}
onFocusInputMobile={() => undefined}
onBlurInputMobile={() => undefined} />
}} />
</ToolsButtonMenu>
</FiltersContainer>
<NoContent />
Expand Down
Loading