Skip to content

Commit

Permalink
switch title as well, in case the tooltip is not shown
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed Feb 12, 2025
1 parent 73b7e0c commit 22832b2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions templates/security.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -83,34 +83,36 @@
<script>
function toggleShowPasswordInput() {
const input = document.querySelector('input[name="_password"]');
if (!input) return;
if (!input) {
return;
}
const a = input.parentElement.querySelector('.input-group-text a');
let tooltipEl;
let tooltipEl = null;
if (a.hasAttribute('aria-describedBy')) {
tooltipEl = document.getElementById(a.getAttribute('aria-describedBy'));
}
const svgs = input.parentElement.querySelectorAll('.input-group-text svg');
let title
let title = '';
if (input.type === 'password') {
// eye-off
title = a.getAttribute('data-hide-title');
input.type = 'text';
svgs[0].parentElement.hidden = true;
svgs[1].parentElement.hidden = false;
} else {
// eye
title = a.getAttribute('data-show-title');
input.type = 'password';
svgs[0].parentElement.hidden = false;
svgs[1].parentElement.hidden = true;
}
// Tooltip
a.ariaLabel = title;
a.title = title;
a.setAttribute('data-bs-original-title', title);
if (tooltipEl) tooltipEl.querySelector('.tooltip-inner').innerText = title;
if (tooltipEl !== null) {
tooltipEl.querySelector('.tooltip-inner').innerText = title;
}
}
</script>
{% endblock %}
Expand Down

0 comments on commit 22832b2

Please sign in to comment.