Ensure address value gets sent in form submit

This commit is contained in:
Eli Ribble 2026-01-31 16:24:41 +00:00
parent caf76abe3b
commit f00b32075a
No known key found for this signature in database

View file

@ -1,16 +1,23 @@
class AddressInput extends HTMLElement {
// make element form-associated
static formAssociated = true;
constructor() {
super();
// Create a shadow DOM
this.attachShadow({mode: "open" });
// Initial render
this.internals = this.attachInternals();
this.render();
// Element references
this._input = this.shadowRoot.querySelector('input');
this._suggestions = this.shadowRoot.querySelector('.suggestions-container');
this._input = this.shadowRoot.querySelector("input");
this._input.addEventListener("input", (event) => {
let value = event.target.value;
const entries = new FormData();
entries.append("address", value);
this.internals.setFormValue(entries);
});
this._suggestions = this.shadowRoot.querySelector(".suggestions-container");
// Bind methods
this._handleInput = this._handleInput.bind(this);