Commit Graph

56 Commits

Author SHA1 Message Date
Elizabeth Mitchell
7dd7a68ae9 fix: forms correctly focus the first invalid control instead of last
Previously all text fields would focus themselves when the form reports validity, meaning the last one got focus. In reality, reportValidity is supposed to focus the first invalid control.

I added a "call" method wrapper around the `onReportValidity` callback that handles focusing logic.

PiperOrigin-RevId: 597904790
2024-01-12 11:43:47 -08:00
Elizabeth Mitchell
3151fd8d90 fix(textfield): error styles not removing when an unrelated control is invalid
The bug: given a form with two required text fields,
1. Try to submit the form, both fields show error.
2. Add a value to the first field.
3. Try to submit the form, the first field does not remove its error.

This is fixed by listening to form submits and clearing the error state if the control is valid.

I refactored `injectFormReportValidityHooks()` into `addFormReportValidListener()` to keep the `OnReportValidity` class cleaner and better identify the problem we're trying to solve.

PiperOrigin-RevId: 597664564
2024-01-11 15:06:22 -08:00
Elizabeth Mitchell
f2ebcdac79 chore(labs): fix onReportValidity called twice with form.reportValidity
PiperOrigin-RevId: 597661314
2024-01-11 14:53:43 -08:00
Elizabeth Mitchell
5c22b2baea test(labs): add more report validity tests
PiperOrigin-RevId: 597598077
2024-01-11 10:47:52 -08:00
Elizabeth Mitchell
e44f6a5a7f test(labs): re-organize report validity tests for unhandled use cases
PiperOrigin-RevId: 597596342
2024-01-11 10:42:11 -08:00
Elizabeth Mitchell
363fc054d3 chore: remove un-actionable todos from labs
PiperOrigin-RevId: 594112463
2023-12-27 15:49:30 -08:00
Elizabeth Mitchell
9973b90981 fix(textfield): counter showing when max length is 0 or removed
Fixes #4998

This also fixes an error being thrown in text field's validator when minlength/maxlength change to out of bounds if they're not set in the correct order.

PiperOrigin-RevId: 594013553
2023-12-27 08:13:58 -08:00
Elizabeth Mitchell
9c5cff8f90 fix(labs): card content not clickable with outline fix
Fixes #5312

PiperOrigin-RevId: 592594621
2023-12-20 10:20:39 -08:00
Elizabeth Mitchell
53ec44b4b8 fix(labs): add card support for high contrast mode
PiperOrigin-RevId: 591038474
2023-12-14 13:38:48 -08:00
Elizabeth Mitchell
2234a1279f chore: fix formAssociated disabled attribute not working
There is out-of-sync state when lit's built-in accessor tries to reflect attributes alongside the getter and setter. Instead, the properties just read from attributes and requestUpdate is called when those attributes change.

PiperOrigin-RevId: 590710159
2023-12-13 14:17:48 -08:00
Elizabeth Mitchell
a0baa4dc10 chore(card): remove host padding and update demo
Cards often have content that extends to the bounds of the card. Instead of adding default padding that must be removed, cards' content should add their own padding as needed.

This makes adding full-width media and dividers easier.

Also moved background z-indices to -1 since the slot doesn't have a display and the z-index wasn't doing anything.

PiperOrigin-RevId: 587883362
2023-12-04 16:58:37 -08:00
Elizabeth Mitchell
52e568ddc8 refactor(text-field): add validator and use validity mixins
PiperOrigin-RevId: 587086864
2023-12-01 12:32:30 -08:00
Elizabeth Mitchell
c53a4194e9 fix(behaviors): validation not reporting when form tries to submit
We handle `form.reportValidity()` with hooks, but we weren't handling `form.submit()`.

PiperOrigin-RevId: 586813244
2023-11-30 15:59:32 -08:00
Elizabeth Mitchell
6a5a245824 chore(behaviors): tabindex attribute not hydrating properly
On construction, setting `tabIndex = 0` should hydrate a tabindex attribute. This behavior was lost since we overrode `Element.prototype.tabIndex`. This change keeps the platform getter/setter behavior and calls requestUpdate another way.

PiperOrigin-RevId: 586738747
2023-11-30 11:33:41 -08:00
Elizabeth Mitchell
36aed9a2df chore(behaviors): update validity anchor on first render
This is needed specifically for text fields. There appears to be an odd Chrome/Safari issue where an element that `delegatesFocus: true` to an inner `<input>` MUST provide that input as the validity anchor. Otherwise, when a form submits or calls `form.reportValidity()`, an error will be thrown.

See https://lit.dev/playground/#gist=6c26e418e0010f7a5aac15005cde8bde for a reproduction.

Unfortunately I couldn't programmatically trigger this behavior in a jasmine test.

PiperOrigin-RevId: 586723140
2023-11-30 10:43:41 -08:00
Elizabeth Mitchell
636a68cfa1 chore(behaviors): don't spread validator state copies
PiperOrigin-RevId: 586487459
2023-11-29 16:36:17 -08:00
Elizabeth Mitchell
c319236cd1 refactor: remove Firefox ARIAMixin polyfills (v119+)
This is now fixed in the latest two versions of Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1785412

PiperOrigin-RevId: 586442947
2023-11-29 13:48:38 -08:00
Elizabeth Mitchell
b5686ea4e0 feat(radio): add required constraint validation
Fixes #4316

PiperOrigin-RevId: 586045132
2023-11-28 11:15:20 -08:00
Elizabeth Mitchell
33c1afece2 refactor(select): use shared validation mixins
PiperOrigin-RevId: 585751913
2023-11-27 13:56:46 -08:00
Elizabeth Mitchell
21432b349f chore(behaviors): add mixinOnReportValidity for text field validation styling
PiperOrigin-RevId: 585698467
2023-11-27 10:51:20 -08:00
vdegenne
e4728bd018 fix(segmented-button): make tap highlight transparent 2023-11-22 10:08:10 +01:00
Elizabeth Mitchell
f7a66a8bbe refactor: add constraint validation mixin
This reduces the copy/paste of validation code. Constraint validation must be synchronous, so a `Validator` helps compute the validity and cache it since the validity must be checked when properties change.

Implemented in checkbox-like controls.

PiperOrigin-RevId: 584380464
2023-11-21 11:22:03 -08:00
Elizabeth Mitchell
8eb1f30e6f refactor: add checkbox validator
Part of adding constraint validation mixins. Each component that participates in constraint validation has different rules and error messages for validating. The `Validator` gives `mixinConstraintValidation()` a way to compute and cache validation.

Other validators will be added later, such as `SelectValidator` and `RadioValidator`

PiperOrigin-RevId: 583508468
2023-11-17 15:59:38 -08:00
Elliott Marquez
2adcb1479a docs: document events in jsdoc
PiperOrigin-RevId: 581041601
2023-11-09 15:25:21 -08:00
Elizabeth Mitchell
1f55d4111f chore(behaviors): update form controls to use shared mixins
PiperOrigin-RevId: 578297611
2023-10-31 14:08:39 -07:00
Elizabeth Mitchell
e7bc633e18 chore(behaviors): add ElementInternals mixin
PiperOrigin-RevId: 576937116
2023-10-26 11:31:33 -07:00
Elizabeth Mitchell
0ebd7c786b chore(card): add styles and tests
PiperOrigin-RevId: 576660710
2023-10-25 15:19:48 -07:00
Elizabeth Mitchell
cbcb89115f chore(card): add basic demo page
PiperOrigin-RevId: 576657778
2023-10-25 15:10:01 -07:00
Elizabeth Mitchell
1b39ab74ce chore(card): add Sass theming apis
PiperOrigin-RevId: 576653714
2023-10-25 14:57:34 -07:00
Elizabeth Mitchell
dcfd35a7a3 chore(card): add boilerplate files
PiperOrigin-RevId: 576646068
2023-10-25 14:31:37 -07:00
Elizabeth Mitchell
c390291687 chore: format files with prettier
PiperOrigin-RevId: 576601342
2023-10-25 11:59:00 -07:00
Elizabeth Mitchell
d1ef1febb6 fix(behaviors): add focusable behavior to labs
PiperOrigin-RevId: 575902929
2023-10-23 12:57:14 -07:00
vdegenne
56070593ce fix(md-item): exclude start slot from hidden overflow 2023-09-27 18:51:28 +02:00
vdegenne
e0871411dd fix(md-item): exclude start slot from hidden overflow 2023-09-27 12:18:36 +02:00
Elizabeth Mitchell
b35212a9ac feat(items): add <md-item> to @material/web/labs
PiperOrigin-RevId: 567734991
2023-09-22 15:42:42 -07:00
Andrew Jakubowicz
f019ac37fe fix(navigationtab)!: change slot names activeIcon and inactiveIcon to active-icon and inactive-icon
PiperOrigin-RevId: 563583060
2023-09-07 16:52:21 -07:00
Elizabeth Mitchell
acd40a2f57 fix(labs): remove font shorthand tokens
PiperOrigin-RevId: 563195627
2023-09-06 13:15:36 -07:00
vdegenne
cc195a9476 fix(badge): center align value text 2023-09-02 12:09:09 +02:00
Elizabeth Mitchell
0e492ade43 chore: remove sass theme utilities
PiperOrigin-RevId: 556915539
2023-08-14 14:39:19 -07:00
Elizabeth Mitchell
0510496e60 chore: avoid this in static context
PiperOrigin-RevId: 554933524
2023-08-08 14:00:25 -07:00
Andrew Jakubowicz
c148bf61fe fix(segmentedbutton): add back shape token
PiperOrigin-RevId: 553265721
2023-08-02 14:59:29 -07:00
Elliott Marquez
86ccec3e7e build: use firebase for hosting and remove url prefixes 2023-07-27 09:17:27 -07:00
Andrew Jakubowicz
6ec3f06429 fix!: rename "lib" directory to "internal"
BREAKING CHANGE: Rename `@material/web/<component>/lib` to `@material/web/<component>/internal`. Prefer not using internal files.

PiperOrigin-RevId: 550633216
2023-07-24 12:02:59 -07:00
Elizabeth Mitchell
d49f9b89e4 fix(focus)!: rename import to md-focus-ring.ts
BREAKING CHANGE: Change `@material/web/focus/focus-ring.js` to `@material/web/focus/md-focus-ring.js`.

PiperOrigin-RevId: 550608428
2023-07-24 10:43:31 -07:00
Andrew Jakubowicz
10f60d23e0 chore: rename e to event
PiperOrigin-RevId: 549039407
2023-07-18 10:16:37 -07:00
Elizabeth Mitchell
243e231a13 feat(all): expose focus-ring parts
PiperOrigin-RevId: 548873009
2023-07-17 20:28:04 -07:00
Elizabeth Mitchell
fd28dd1a5b chore(all): move focus tokens to focus ring element
PiperOrigin-RevId: 548872335
2023-07-17 20:24:46 -07:00
Andrew Jakubowicz
cc786d1f73 fix(segmentedbutton)!: remove with-* token prefixes
PiperOrigin-RevId: 546951852
2023-07-10 12:44:16 -07:00
Andrew Jakubowicz
28f897b5ea fix(labs): compound properties should have kebab-case attributes
PiperOrigin-RevId: 542416783
2023-06-21 18:16:12 -07:00
Elizabeth Mitchell
1790a5bbf8 chore: remove closure comments from static blocks
PiperOrigin-RevId: 539772537
2023-06-12 15:07:36 -07:00