editor: don't autofocus by default

Autofocus prompts the browser to scroll to the editor when the page
loads, which makes little to no sense on topic pages where the important
information is at the top.
This commit is contained in:
Lephe 2020-10-31 22:15:03 +01:00
parent 36ccb16536
commit bb6450bda2
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@
{% endfor %}
{% endif %}
{{ widget_editor.text_editor(form.message, label=False) }}
{{ widget_editor.text_editor(form.message, label=False, autofocus=True) }}
<div>{{ form.submit(class_='bg-ok') }}</div>
</form>

View File

@ -1,11 +1,11 @@
{% macro text_editor(field, label=True) %}
{% macro text_editor(field, label=True, autofocus=false) %}
{{ field.label if label }}
{{ field() }}
<script>
window.addEventListener("load", function(){
var simplemde = new SimpleMDE({
element: document.getElementById("{{field.name}}"),
autofocus: true,
autofocus: {{ "true" if autofocus else "false" }},
autosave: {
enabled: true,
uniqueId: "{{ request.path }}+{{ field.name }}",