[FIX] website, website_form: fix anchor link redirects
Before this commit, links scrolling to an anchor with a special character did not work and displayed a traceback. The issue was that to check that the anchor is valid, we don't need to check that the anchor is a valid url as we have been doing since these commits [1], [2]. But we only need to check if the jQuery selector is valid to correctly target the element to which the page must scroll. Indeed, the anchor widget returns stuff like 'ok%C3%A9%25' when typing 'oké%' wich is not valid jQuery selector. It has to be encoded to '#ok\\%C3\\%A9\\%25' to be valid and that's what this commit does. We also changed the way to display a new anchor to the user in this commit. Before, we showed the anchor unencoded in a notification and now we show it encoded. That way, if the user copies the anchor from the notification, it's the real anchor. Also, this commit detect if the success URL of the redirect of a from is the current page to perform a scroll to the anchor instead of a redirect. To make this comparison, we needed to add the url code of the language of the current page to the session info. Also, before this commit, the page froze when we clicked on the "submit" button of a form that redirected to an anchor that did not exist. [1]: https://github.com/odoo/odoo/commit/0abfaeda96c2eaa868cc7fc5fa1926dfa90fc420 [2]: https://github.com/odoo/odoo/commit/b492bde6a121be1c15ed90ce0827fcfd72a12f5c task-2172312 closes odoo/odoo#82059 Signed-off-by:Romain Derie (rde) <rde@odoo.com>
Showing
- addons/website/models/ir_http.py 1 addition, 0 deletionsaddons/website/models/ir_http.py
- addons/website/static/src/js/content/snippets.animation.js 3 additions, 5 deletionsaddons/website/static/src/js/content/snippets.animation.js
- addons/website/static/src/js/editor/snippets.options.js 1 addition, 2 deletionsaddons/website/static/src/js/editor/snippets.options.js
- addons/website_form/static/src/snippets/s_website_form/000.js 25 additions, 6 deletions...ns/website_form/static/src/snippets/s_website_form/000.js
Loading