diff --git a/docs/assets/styles/docs.css b/docs/assets/styles/docs.css index c553cbbb..a33e3dd4 100644 --- a/docs/assets/styles/docs.css +++ b/docs/assets/styles/docs.css @@ -490,6 +490,7 @@ kbd, .markdown-section p.tip code, .markdown-section p.warn code { background-color: var(--sl-color-neutral-100); + white-space: nowrap; } /* Sponsorship callouts */ diff --git a/docs/getting-started/form-controls.md b/docs/getting-started/form-controls.md index db1ea903..0a610458 100644 --- a/docs/getting-started/form-controls.md +++ b/docs/getting-started/form-controls.md @@ -4,13 +4,11 @@ Every Shoelace component makes use of a [shadow DOM](https://developer.mozilla.o Shoelace solves this problem by using the [`formdata`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/formdata_event) event, which is [available in all modern browsers](https://caniuse.com/mdn-api_htmlformelement_formdata_event). This means, when a form is submitted, Shoelace form controls will automatically append their values to the `FormData` object that's used to submit the form. In most cases, things will "just work." However, if you're using a form serialization library, it might need to be adapted to recognize Shoelace form controls. +?> Shoelace uses event listeners to intercept the form's `formdata` and `submit` events. This allows it to inject data and trigger validation as necessary. If you're also attaching an event listener to the form, _you must attach it after Shoelace form controls are connected to the DOM_, otherwise your logic will run before Shoelace has a chance to inject form data and validate form controls. + ?> If you're using an older browser that doesn't support the `formdata` event, a lightweight polyfill will be automatically applied to ensure forms submit as expected. -## A Note About Event Handling - -Shoelace uses event listeners to intercept the form's `formdata` and `submit` events. This allows it to inject data and trigger validation as necessary. If you're also attaching an event listener to the form, _you must attach it after Shoelace form controls are connected to the DOM_, otherwise your logic will run before Shoelace has a chance to inject form data and validate form controls. - -## Form Serialization +## Data Serialization Serialization is just a fancy word for collecting form data. If you're relying on standard form submissions, e.g. `
@@ -119,8 +118,8 @@ To restrict a value to a specific [pattern](https://developer.mozilla.org/en-US/ + ```