Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOGUE] validation de formulaire sans ruiner/casser les événements ajoutés par d'autres javascript #9498

Open
joejoseph00 opened this issue Dec 15, 2022 · 5 comments

Comments

@joejoseph00
Copy link
Member

joejoseph00 commented Dec 15, 2022

Information nécessaire

Description du bogue
Lorsqu'un formulaire est enveloppé dans

<div class="custom-wrapper wb-frmvld">' 
</div>

Avec ce config la validation wet-boew est activée/initialisé. Cela peut briser des fonctionnalités (à re-confirmer, je travail là dessus) comme les conditionnels des formulaires Web fournis par le module Webform conçu pour Drupal 9 ou Drupal 10. Les conditionnels sert également de Javascript alors il y a un conflit entre
Wet-boew (tous les versions) https://wet-boew.github.io/v4.0-ci/demos/formvalid/formvalid-en.html
et
Webform (tous les versions). https://www.drupal.org/project/webform

Pour le reproduire
Étapes pour reproduire le problème :

  1. Créer un nouveau formulaire web avec la distribution wxt du dernier cri https://www.drupal.org/project/wxt .
  2. Met un préfix: '#prefix': '<div class="custom-wrapper wb-frmvld">'
  3. Met un suffix: '#suffix': '</div>'
  4. Ajoute des conditions pour un champ, disons visibilité d'un champ dépend sur les options d'un autre champ.
  5. Visite l'interface web du formulaire créé
  6. Aucune condition ne fonctionnera
  7. Enlève le suffix/prefix
  8. Test à nouveau, tout les conditions fonctionnera comme conçu.

Scénario attendu
Tout les conditions programmé à travers la configuration du formulaire devrait fonctionner avec ou sans l'élément div class="wb-frmvld"

Qui devrait travailler à corriger ce problem?
Je vais le faire, je veux contribuer

Information additionnelle (optionel)

Version de WET-BOEW/GCWeb que vous utilisez
v4.0.43.1 à v4.0.50+

Ordinateur/Téléphone intelligent

  • OS = tous
  • Browser (tous)
  • Version (tous)

Captures d'écrans
Aucun

Contexte additionnel

LE TRAVAIL À FAIRE
Les instructions de construction et de compilation de wet-boew sont ici :

https://wet-boew.github.io/v4.0-ci/docs/start-en.html

Déboguer la fonctionnalité liée à wb-frmvld (validation de formulaire de wet-boew), faire particulièrement attention à tout javascript qui supprime des événements, s'assure que bind sert des espaces de noms spécifique pour wet-boew qui n'entrent pas en conflit avec d'autres, changer la logique pour supprimer les événements de wet-boew avec noms et régénérer les événements en utilisant les événements de wet-boew avec un espace de nom (namespace), autant possible ne pas supprimer les événements existants durant l'initialisation, examiner si les changements DOM cassent les conditionnels du formulaire web, déboguer et corriger le problème.

@joejoseph00
Copy link
Member Author

Je travail là dessus.

@joejoseph00
Copy link
Member Author

Il fonctionne comme prévu avec la bibliothèque wet-boew v4.0.50.
ça se peut que mes tests était compromis par un autre problème non-relié à Wet-boew dans ce cas.

@joejoseph00
Copy link
Member Author

Certain types de champs ont ce problème, d'autres comme text input n'ont pas de problème.
https://www.drupal.org/project/wxt/issues/3327296#comment-14839431

@joejoseph00
Copy link
Member Author

joejoseph00 commented Jan 25, 2023

**wb-frmvlid of the wet-boew removes the events (change & state:checked) and events (change & state:value & keyup) from the field checkbox and radio type in Webform, respectively.

It breaks the conditional functionality of Webform.

To fix this issue, the wet-boew library could carefully use namespaces for adding (.on) and removing (.off) it's wb-frmvld related form events instead of removing elements just reset it's own namespaced events as needed, avoid changing non-namespaced events like change and keyup events and state:checked attribute just remove the eventname.namespace event , preventing the breaking of other modules functionality and basically avoid being a poor partner of the rest of the web.

Example of a better approach:

https://api.jquery.com/event.namespace/

with that said, I think the problem is that the wb-frmvld functionality is removing the elements and their events , moving things around and rebuilding them from scratch without their original events.

I looked at the wet-boew source code just now, nothing obvious other than elements removed and added to the dom not sure what else could be causing this because I don't see the use of .off at all, unless there's another equivalent method I'm not familiar with.

@joejoseph00
Copy link
Member Author

Thanks to @nancy-hebert for this, the build and compile instructions are here:

https://wet-boew.github.io/v4.0-ci/docs/start-en.html

I haven't tested these build/compile instructions yet but it's a good starting point.

If anyone wants to attempt to help fix this you'll need the compile instructions to build test code for wet-boew.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant