From d569fd560fc615b31b61f056f2a0135b02f9040c Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 15 Jan 2022 02:04:49 +0100 Subject: [PATCH] Problem: search results have edit link while on read side Solution: only use /edit/ link when editing --- editor/src/editor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/src/editor.js b/editor/src/editor.js index 63f452d..4e56ff1 100644 --- a/editor/src/editor.js +++ b/editor/src/editor.js @@ -121,6 +121,8 @@ function showSearchResultsExtended(element, template, searchTool, query, input, selectedPos = $lc.find('li').index(selected[0]) } + const isEditing = window.location.pathname.match(/^\/edit\//) + let $ul = el('ul', _.map(results, (hit, i) => { let div = el('div', []); @@ -133,7 +135,7 @@ function showSearchResultsExtended(element, template, searchTool, query, input, ]; if (hit.ref) { children = hit.ref ? [el('a', children)] : children; - children[0].setAttribute('href', '/edit/' + hit.ref) + children[0].setAttribute('href', (isEditing ? '/edit/' : '/') + hit.ref) } const li = el('li', children) if (selectedPos === i) li.classList.add('selected')