@@ -187,23 +187,6 @@ const RestSettingsNotice = () => {
187187 )
188188}
189189
190- const SaveSettingsNotice = ( ) => {
191- const [ isDismissed , setIsDismissed ] = useState ( false )
192-
193- if ( isDismissed ) {
194- return null
195- }
196-
197- return (
198- < div className = "notice notice-success is-dismissible" >
199- < p > { __ ( 'Settings saved.' , i18n ) } </ p >
200- < button type = "button" className = "notice-dismiss" onClick = { ( ) => setIsDismissed ( true ) } >
201- < span className = "screen-reader-text" > Dismiss this notice.</ span >
202- </ button >
203- </ div >
204- )
205- }
206-
207190// Confirmation dialog when disabling a block that is dependent on another block.
208191const ToggleBlockDialog = ( {
209192 blockName,
@@ -247,13 +230,13 @@ const ToggleBlockDialog = ( {
247230 )
248231}
249232
250- // TODO: Proper tab nesting
251- // Implement other highlight without admin base
233+ // Side navigation with the save changes button and search on tabs
252234const Sidenav = ( {
253235 currentTab,
254236 handleTabChange,
255237 handleSettingsSave,
256238 currentSearch,
239+ isSaving,
257240} ) => {
258241 const tabList = useMemo ( ( ) => [
259242 {
@@ -406,7 +389,7 @@ const Sidenav = ( {
406389 className = "s-save-changes"
407390 onClick = { handleSettingsSave }
408391 >
409- { __ ( 'Save Changes' , i18n ) }
392+ { isSaving ? < Spinner /> : __ ( 'Save Changes' , i18n ) }
410393 </ button >
411394 </ nav >
412395 </ >
@@ -436,27 +419,24 @@ const Settings = () => {
436419 const [ unsavedChanges , setUnsavedChanges ] = useState ( { } )
437420 const [ currentTab , setCurrentTab ] = useState ( 'editor-settings' )
438421 const [ currentSearch , setCurrentSearch ] = useState ( '' )
422+ const [ isSaving , setIsSaving ] = useState ( false )
439423
440424 const handleSettingsChange = useCallback ( newSettings => {
441425 setSettings ( prev => ( { ...prev , ...newSettings } ) )
442426 setUnsavedChanges ( prev => ( { ...prev , ...newSettings } ) )
443427 } , [ ] )
444428
445429 const handleSettingsSave = useCallback ( ( ) => {
446- console . log ( unsavedChanges ) // eslint-disable-line no-console
447430 if ( Object . keys ( unsavedChanges ) . length === 0 ) {
448431 return
449432 }
433+ setIsSaving ( true )
450434 const model = new models . Settings ( unsavedChanges )
451435 model . save ( ) . then ( ( ) => {
452- if ( document . querySelector ( '.s-save-settings-notice' ) ) {
453- createRoot (
454- document . querySelector ( '.s-save-settings-notice' )
455- ) . render (
456- < SaveSettingsNotice />
457- )
458- window . scrollTo ( { top : 0 , behavior : 'smooth' } )
459- }
436+ // Add a little more time for the spinner for better feedback
437+ setTimeout ( ( ) => {
438+ setIsSaving ( false )
439+ } , 500 )
460440 } )
461441 setUnsavedChanges ( { } )
462442 } , [ unsavedChanges , settings ] )
@@ -482,6 +462,7 @@ const Settings = () => {
482462 handleTabChange = { setCurrentTab }
483463 handleSettingsSave = { handleSettingsSave }
484464 currentSearch = { currentSearch }
465+ isSaving = { isSaving }
485466 />
486467 < article className = "s-box" id = { currentTab } >
487468 < Searchbar currentSearch = { currentSearch } handleSearchChange = { setCurrentSearch } />
0 commit comments