sign_up: fix suggestions error when navigating away

When navigating away from the page, the field receives the 'focusout'
event – but stops to be present in the DOM.

Thus we need to check that the DOM element is actually present.
This commit is contained in:
Pierre de La Morinerie 2019-12-19 17:45:14 +01:00
parent fccbbdf53a
commit a5f2c84cbf
2 changed files with 2 additions and 2 deletions

View file

@ -13,7 +13,7 @@ delegate('focusout', userNewEmailSelector, () => {
const suggestedEmailSpan = document.querySelector(emailSuggestionSelector);
const suggestion = suggest(userEmailInput.value);
if (suggestion && suggestion.full) {
if (suggestion && suggestion.full && suggestedEmailSpan) {
suggestedEmailSpan.innerHTML = suggestion.full;
show(document.querySelector(suggestionsSelector));
} else {

View file

@ -8,7 +8,7 @@
= f.label :email, "Email"
= f.text_field :email, autofocus: true, placeholder: "Votre adresse email"
.suspect-email
.suspect-email.hidden
.email-suggestion-title
Voulez-vous dire
%span.email-suggestion-address blabla@gmail.com