Skip to content

Commit

Permalink
fix(dialog): buttons not reflecting value attribute when setting prop…
Browse files Browse the repository at this point in the history
…erty

Fixes #5409

PiperOrigin-RevId: 600541901
  • Loading branch information
asyncLiz authored and copybara-github committed Jan 22, 2024
1 parent fcdfa33 commit 35913a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions button/internal/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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') ?? '';
Expand Down
12 changes: 10 additions & 2 deletions iconbutton/internal/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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') ?? '';
Expand Down

0 comments on commit 35913a6

Please sign in to comment.