@@ -19,7 +19,7 @@ import {
1919import { Link } from '@tanstack/react-router' ;
2020import { TrashIcon } from 'components/icons' ;
2121import { type FC , useEffect , useState } from 'react' ;
22- import { Controller , type SubmitHandler , useFieldArray , useForm } from 'react-hook-form' ;
22+ import { Controller , type SubmitHandler , useFieldArray , useForm , useWatch } from 'react-hook-form' ;
2323
2424import { setMonacoTheme } from '../../../config' ;
2525import {
@@ -124,6 +124,10 @@ type Inputs = {
124124 value : PayloadOptions ;
125125} ;
126126
127+ const persistCompressionType = ( compressionType : CompressionType ) => {
128+ uiState . topicSettings . produceRecordCompression = compressionType ;
129+ } ;
130+
127131// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: complex business logic
128132const PublishTopicForm : FC < { topicName : string } > = ( { topicName } ) => {
129133 const toast = useToast ( ) ;
@@ -135,7 +139,6 @@ const PublishTopicForm: FC<{ topicName: string }> = ({ topicName }) => {
135139 handleSubmit,
136140 setError,
137141 formState : { isSubmitting, errors } ,
138- watch,
139142 clearErrors,
140143 } = useForm < Inputs > ( {
141144 defaultValues : {
@@ -158,8 +161,8 @@ const PublishTopicForm: FC<{ topicName: string }> = ({ topicName }) => {
158161 name : 'headers' ,
159162 } ) ;
160163
161- const keyPayloadOptions = watch ( 'key' ) ;
162- const valuePayloadOptions = watch ( 'value' ) ;
164+ const keyPayloadOptions = useWatch ( { control , name : 'key' } ) ;
165+ const valuePayloadOptions = useWatch ( { control , name : 'value' } ) ;
163166
164167 const [ isKeyExpanded , setKeyExpanded ] = useState ( false ) ;
165168 useEffect ( ( ) => {
@@ -226,8 +229,8 @@ const PublishTopicForm: FC<{ topicName: string }> = ({ topicName }) => {
226229
227230 const availableValues = api . schemaSubjects ?. filter ( ( x ) => ! x . isSoftDeleted ) ?? [ ] ;
228231
229- const keySchemaName = watch ( 'key.schemaName' ) ;
230- const valueSchemaName = watch ( 'value.schemaName' ) ;
232+ const keySchemaName = useWatch ( { control , name : 'key.schemaName' } ) ;
233+ const valueSchemaName = useWatch ( { control , name : 'value.schemaName' } ) ;
231234
232235 // biome-ignore lint/complexity: This will be refactored anyway as part of MobX removal
233236 const onSubmit : SubmitHandler < Inputs > = async ( data ) => {
@@ -236,7 +239,7 @@ const PublishTopicForm: FC<{ topicName: string }> = ({ topicName }) => {
236239 req . partitionId = data . partition ;
237240 req . compression = data . compressionType ;
238241
239- uiState . topicSettings . produceRecordCompression = data . compressionType ;
242+ persistCompressionType ( data . compressionType ) ;
240243
241244 // Headers
242245 for ( const h of data . headers ) {
0 commit comments