File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { RootState } from '../../modules';
4
4
import PublishURLSetting from '../../components/write/PublishURLSetting' ;
5
5
import { escapeForUrl } from '../../lib/utils' ;
6
6
import { changeUrlSlug } from '../../modules/write' ;
7
+ import { useMount } from 'react-use' ;
7
8
8
9
interface OwnProps { }
9
10
type StateProps = ReturnType < typeof mapStateToProps > ;
@@ -28,16 +29,21 @@ const PublishURLSettingContainer: React.FC<PublishURLSettingContainerProps> = ({
28
29
changeUrlSlug,
29
30
} ) => {
30
31
const defaultUrlSlug = escapeForUrl ( title ) ;
31
- const urlSlugToShow = urlSlug || defaultUrlSlug ;
32
32
const onChangeUrlSlug = useCallback (
33
33
( urlSlug : string ) => changeUrlSlug ( urlSlug ) ,
34
34
[ changeUrlSlug ] ,
35
35
) ;
36
+
37
+ useMount ( ( ) => {
38
+ if ( ! urlSlug ) {
39
+ changeUrlSlug ( defaultUrlSlug ) ;
40
+ }
41
+ } ) ;
36
42
if ( ! username ) return null ;
37
43
return (
38
44
< PublishURLSetting
39
45
username = { username }
40
- urlSlug = { urlSlugToShow }
46
+ urlSlug = { urlSlug }
41
47
onChangeUrlSlug = { onChangeUrlSlug }
42
48
/>
43
49
) ;
You can’t perform that action at this time.
0 commit comments