Skip to content

Commit e4a3e32

Browse files
committed
Pass show_edit_format_selector prop to use_edit_format_compacting to optimize layout calculations
1 parent 3d07d79 commit e4a3e32

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/ui/src/components/editor/panel/PromptField/PromptField.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
306306
format_truncated_ref,
307307
format_before_after_ref,
308308
format_diff_ref
309-
} = use_edit_format_compacting()
309+
} = use_edit_format_compacting(props.show_edit_format_selector)
310310

311311
return (
312312
<div className={styles.container}>

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-edit-format-compacting.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useRef, useLayoutEffect } from 'react'
22
import { use_compacting } from '@shared/hooks'
33

4-
export const use_edit_format_compacting = () => {
4+
export const use_edit_format_compacting = (is_visible?: boolean) => {
55
const { container_ref, compact_step, report_width } = use_compacting(4)
66
const format_whole_ref = useRef<HTMLButtonElement>(null)
77
const format_truncated_ref = useRef<HTMLButtonElement>(null)
@@ -27,7 +27,7 @@ export const use_edit_format_compacting = () => {
2727

2828
report_width(width, compact_step)
2929
}
30-
}, [compact_step, report_width])
30+
}, [compact_step, report_width, is_visible])
3131

3232
return {
3333
container_ref,

0 commit comments

Comments
 (0)