Skip to content
Snippets Groups Projects
Unverified Commit 756f8f9f authored by Franz Sauerwald's avatar Franz Sauerwald Committed by GitHub
Browse files

fixes #1635: focus the contact form field on open (#1665)

* fix #1635: focus modal autofocus fields

* fix selector & add autofocus to message field

* feat: rewrite without jquery, as typescript

* use indentation of 4 spaces

* change _ to -
parent 27b28b5b
Branches
No related tags found
No related merge requests found
......@@ -70,6 +70,7 @@
<script type="module" src="{% static 'js/csrf-utils.js' %}"></script>
<script type="module" src="{% static 'js/base-template.js' %}"></script>
<script type="text/javascript">
activateTooltips = function(selector = "") {
var tooltipTriggerList = [].slice.call(document.querySelectorAll(selector + ' [data-bs-toggle="tooltip"]'))
......
......@@ -32,7 +32,7 @@
</div>
<div class="mb-3">
<label for="{{ modal_id }}MessageText" class="control-label">{% trans 'Message' %}:</label>
<textarea class="form-control" id="{{ modal_id }}MessageText" style="resize:vertical;min-height:150px;"></textarea>
<textarea autofocus class="form-control" id="{{ modal_id }}MessageText" style="resize:vertical;min-height:150px;"></textarea>
</div>
</div>
<div class="modal-footer">
......
// This file contains all typescript code for the base.html template.
// Fix autofocus on bootstrap modals -> Focus the first element with `autofocus` attribute
document.addEventListener("shown.bs.modal", (e) => {
if (!e.target) return;
const modalEl = e.target as HTMLElement;
const autofocusEl = modalEl.querySelector("[autofocus]") as HTMLElement;
if (autofocusEl) {
autofocusEl.focus();
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment