@@ -78,6 +78,7 @@ export function useCreateChannelForm({
7878 > ( null ) ;
7979 const [ typePopoverOpen , setTypePopoverOpen ] = React . useState ( false ) ;
8080 const nameInputRef = React . useRef < HTMLInputElement > ( null ) ;
81+ const visibilityTouchedRef = React . useRef ( false ) ;
8182
8283 const templatesQuery = useChannelTemplatesQuery ( ) ;
8384 const templates = templatesQuery . data ?? [ ] ;
@@ -96,6 +97,7 @@ export function useCreateChannelForm({
9697 setErrorMessage ( null ) ;
9798 setSelectedTemplateId ( null ) ;
9899 setTypePopoverOpen ( false ) ;
100+ visibilityTouchedRef . current = false ;
99101
100102 if ( ! autoFocusName ) return ;
101103
@@ -123,7 +125,7 @@ export function useCreateChannelForm({
123125 if ( ! templateId ) {
124126 setSelectedTemplateId ( null ) ;
125127 setDescription ( "" ) ;
126- setVisibility ( "open" ) ;
128+ if ( ! visibilityTouchedRef . current ) setVisibility ( "open" ) ;
127129 setErrorMessage ( null ) ;
128130 return ;
129131 }
@@ -135,7 +137,7 @@ export function useCreateChannelForm({
135137
136138 setSelectedTemplateId ( templateId ) ;
137139 setDescription ( template . description ?? "" ) ;
138- setVisibility ( template . visibility ) ;
140+ if ( ! visibilityTouchedRef . current ) setVisibility ( template . visibility ) ;
139141 setErrorMessage ( null ) ;
140142 } ,
141143 [ templates ] ,
@@ -195,7 +197,10 @@ export function useCreateChannelForm({
195197 setErrorMessage ( null ) ;
196198 } ,
197199 visibility,
198- setVisibility,
200+ setVisibility : ( value : ChannelVisibility ) => {
201+ visibilityTouchedRef . current = true ;
202+ setVisibility ( value ) ;
203+ } ,
199204 ephemeral,
200205 setEphemeral,
201206 durationLabel,
0 commit comments