Skip to content

Commit

Permalink
use password jquery removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Oct 21, 2023
1 parent 068c386 commit c393e78
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions _dev/js/theme/components/password/usePasswordPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ const watchPassword = async (
const feedback = getPasswordStrengthFeedback(result.score);
const passwordLength = passwordValue.length;
const popoverContent = [];
const oldPopoverInstance = window.bootstrap.Popover.getInstance(elementInput);

$(elementInput).popover('dispose');
oldPopoverInstance?.dispose();

feedbackContainer.style.display = passwordValue === '' ? 'none' : 'block';

Expand All @@ -79,11 +80,12 @@ const watchPassword = async (
}
});

$(elementInput).popover({
const newPopoverInstance = window.bootstrap.Popover.getOrCreateInstance(elementInput, {
html: true,
placement: 'top',
content: popoverContent.join('<br/>'),
}).popover('show');
});
newPopoverInstance.show();

const passwordLengthValid = passwordLength >= parseInt(elementInput.dataset.minlength, 10)
&& passwordLength <= parseInt(elementInput.dataset.maxlength, 10);
Expand Down Expand Up @@ -164,7 +166,9 @@ const usePasswordPolicy = (selector) => {
// eslint-disable-next-line max-len
elementInput.addEventListener('keyup', () => watchPassword(elementInput, feedbackContainer, hints));
elementInput.addEventListener('blur', () => {
$(elementInput).popover('dispose');
const oldPopoverInstance = window.bootstrap.Popover.getInstance(elementInput);

oldPopoverInstance?.dispose();
});
}
}
Expand Down

0 comments on commit c393e78

Please sign in to comment.