diff --git a/web/client/components/share/SharePanel.jsx b/web/client/components/share/SharePanel.jsx index 962faefefa..0ba2fcfec5 100644 --- a/web/client/components/share/SharePanel.jsx +++ b/web/client/components/share/SharePanel.jsx @@ -70,6 +70,7 @@ class SharePanel extends React.Component { shareUrlReplaceString: PropTypes.string, shareApiUrl: PropTypes.string, shareConfigUrl: PropTypes.string, + currSectionId: PropTypes.string, embedPanel: PropTypes.bool, embedOptions: PropTypes.object, showAPI: PropTypes.bool, @@ -213,7 +214,7 @@ class SharePanel extends React.Component { getShareUrl = () => { const { settings, advancedSettings, mapType, viewerOptions } = this.props; const shouldRemoveSectionId = !settings.showSectionId && advancedSettings && advancedSettings.sectionId; - let shareUrl = getSharedGeostoryUrl(removeQueryFromUrl(this.props.shareUrl), shouldRemoveSectionId); + let shareUrl = getSharedGeostoryUrl(removeQueryFromUrl(this.props.shareUrl), shouldRemoveSectionId, this.props.currSectionId); if (settings.bboxEnabled && advancedSettings && advancedSettings.bbox && this.state.bbox) shareUrl = `${shareUrl}?bbox=${this.state.bbox}`; if (settings.showHome && advancedSettings && advancedSettings.homeButton) shareUrl = `${shareUrl}?showHome=true`; if (settings.centerAndZoomEnabled && advancedSettings && advancedSettings.centerAndZoom) { diff --git a/web/client/plugins/Share.jsx b/web/client/plugins/Share.jsx index 035d47dc50..f738484caa 100644 --- a/web/client/plugins/Share.jsx +++ b/web/client/plugins/Share.jsx @@ -80,12 +80,14 @@ const Share = connect(createSelector([ ? [cameraPosition.longitude, cameraPosition.latitude] : map?.center; return center && ConfigUtils.getCenter(center); - } -], (isVisible, version, map, mapType, context, settings, formatCoords, point, isScrollPosition, viewerOptions, center) => ({ + }, + state => state.geostory?.currentPage?.sectionId +], (isVisible, version, map, mapType, context, settings, formatCoords, point, isScrollPosition, viewerOptions, center, currSectionId) => ({ isVisible, shareUrl: location.href, shareApiUrl: getApiUrl(location.href), shareConfigUrl: getConfigUrl(location.href, ConfigUtils.getConfigProp('geoStoreUrl')), + currSectionId, version, viewerOptions, mapType, diff --git a/web/client/utils/ShareUtils.js b/web/client/utils/ShareUtils.js index 55b637b358..e77d42f3c3 100644 --- a/web/client/utils/ShareUtils.js +++ b/web/client/utils/ShareUtils.js @@ -103,7 +103,7 @@ export const removeQueryFromUrl = (url = '') => { const formatHash = Url.format({ ...parseHash, query: null, search: null }); return Url.format({ ...parsedUrl, query: null, search: null, hash: formatHash ? `#${formatHash}` : null }); }; -export const getSharedGeostoryUrl = (url = '', removeScroll = false) => { +export const getSharedGeostoryUrl = (url = '', removeScroll = false, currSectionId) => { if (url.match(/\#\/(geostory)/)) { let geostoryUrl = url.match(/\/(geostory)\/((shared)|(newgeostory))/) ? url @@ -113,6 +113,8 @@ export const getSharedGeostoryUrl = (url = '', removeScroll = false) => { const parsedUrl = geostoryUrl.split('#')[1]?.split('/'); if (parsedUrl.length === 6 && parsedUrl.includes('shared')) geostoryUrl = replace(geostoryUrl, `/section/${parsedUrl[parsedUrl.length - 1]}`, ''); if (parsedUrl.length === 8 && parsedUrl.includes('shared')) geostoryUrl = replace(geostoryUrl, `/section/${parsedUrl[parsedUrl.length - 3]}/column/${parsedUrl[parsedUrl.length - 1]}`, ''); + } else if ( currSectionId && !removeScroll && !geostoryUrl.includes('section') ) { + geostoryUrl = geostoryUrl + '/section/' + currSectionId; } return geostoryUrl;