Skip to content

Commit

Permalink
Edit Site: Append query vars in NavigateToLink properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Feb 25, 2020
1 parent fef82a7 commit 5432e83
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,10 @@ function LinkControl( {
);
};

const viewerSlotFillProps = useMemo( () => ( { url: value.url } ), [
value.url,
] );
const viewerSlotFillProps = useMemo(
() => ( { url: value && value.url } ),
[ value && value.url ]
);
return (
<div
tabIndex={ -1 }
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@wordpress/i18n": "file:../i18n",
"@wordpress/media-utils": "file:../media-utils",
"@wordpress/notices": "file:../notices",
"@wordpress/url": "file:../url",
"file-saver": "^2.0.2",
"jszip": "^3.2.2"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/navigate-to-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { useState, useEffect, useMemo } from '@wordpress/element';
import { addQueryArgs } from '@wordpress/url';
import { select } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
Expand All @@ -22,7 +23,7 @@ export default function NavigateToLink( {
const effect = async () => {
try {
const { success, data } = await fetch(
`${ url }?_wp-find-template`
addQueryArgs( url, { '_wp-find-template': true } )
).then( ( res ) => res.json() );
if ( success ) {
let newTemplateId = data.ID;
Expand Down

0 comments on commit 5432e83

Please sign in to comment.