From 35913a6ea42776f2c402d879067ae772833e52b5 Mon Sep 17 00:00:00 2001 From: Elizabeth Mitchell Date: Mon, 22 Jan 2024 12:48:16 -0800 Subject: [PATCH] fix(dialog): buttons not reflecting value attribute when setting property Fixes #5409 PiperOrigin-RevId: 600541901 --- button/internal/button.ts | 12 ++++++++++-- iconbutton/internal/icon-button.ts | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/button/internal/button.ts b/button/internal/button.ts index 51969abc0..15f418c37 100644 --- a/button/internal/button.ts +++ b/button/internal/button.ts @@ -14,8 +14,8 @@ import {ARIAMixinStrict} from '../../internal/aria/aria.js'; import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js'; import { FormSubmitter, - type FormSubmitterType, setupFormSubmitter, + type FormSubmitterType, } from '../../internal/controller/form-submitter.js'; import { dispatchActivationClick, @@ -78,9 +78,17 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter { @property({type: Boolean, attribute: 'has-icon', reflect: true}) hasIcon = false; + /** + * The default behavior of the button. May be "text", "reset", or "submit" + * (default). + */ @property() type: FormSubmitterType = 'submit'; - @property() value = ''; + /** + * The value added to a form with the button's name when the button submits a + * form. + */ + @property({reflect: true}) value = ''; get name() { return this.getAttribute('name') ?? ''; diff --git a/iconbutton/internal/icon-button.ts b/iconbutton/internal/icon-button.ts index 8dfaa299c..1f33f31a1 100644 --- a/iconbutton/internal/icon-button.ts +++ b/iconbutton/internal/icon-button.ts @@ -16,8 +16,8 @@ import {ARIAMixinStrict} from '../../internal/aria/aria.js'; import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js'; import { FormSubmitter, - type FormSubmitterType, setupFormSubmitter, + type FormSubmitterType, } from '../../internal/controller/form-submitter.js'; import {isRtl} from '../../internal/controller/is-rtl.js'; import { @@ -91,9 +91,17 @@ export class IconButton extends iconButtonBaseClass implements FormSubmitter { */ @property({type: Boolean, reflect: true}) selected = false; + /** + * The default behavior of the button. May be "text", "reset", or "submit" + * (default). + */ @property() type: FormSubmitterType = 'submit'; - @property() value = ''; + /** + * The value added to a form with the button's name when the button submits a + * form. + */ + @property({reflect: true}) value = ''; get name() { return this.getAttribute('name') ?? '';