diff --git a/addons/website/static/src/js/editor/widget_link.js b/addons/website/static/src/js/editor/widget_link.js index 65b9ddb1d2b..415d512d1fb 100644 --- a/addons/website/static/src/js/editor/widget_link.js +++ b/addons/website/static/src/js/editor/widget_link.js @@ -54,8 +54,19 @@ weWidgets.LinkTools.include({ if ($selectMenu.data("anchor-for") !== urlInputValue) { // avoid useless query $pageAnchor.toggleClass('d-none', !isFromWebsite); $selectMenu.empty(); - const always = () => $pageAnchor.find('we-toggler').text('\u00A0'); - wUtils.loadAnchors(urlInputValue, this.$editable[0].ownerDocument.body).then(anchors => { + const always = () => { + const anchor = `#${urlInputValue.split('#')[1]}`; + let weTogglerText = '\u00A0'; + if (anchor) { + const weButtonEls = $selectMenu[0].querySelectorAll('we-button'); + if (Array.from(weButtonEls).some(el => el.textContent === anchor)) { + weTogglerText = anchor; + } + } + $pageAnchor[0].querySelector('we-toggler').textContent = weTogglerText; + }; + const urlWithoutHash = urlInputValue.split("#")[0]; + wUtils.loadAnchors(urlWithoutHash, this.$editable[0].ownerDocument.body).then(anchors => { for (const anchor of anchors) { const $option = $(''); $option.text(anchor);