Skip to content

Commit

Permalink
fix(item): pass the correct type property to the button tag
Browse files Browse the repository at this point in the history
fixes #14740
  • Loading branch information
brandyscarney committed Jul 11, 2018
1 parent 02a0b6e commit 5f8b02e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,10 @@ declare global {
*/
'routerDirection': RouterDirection;
'state': 'valid' | 'invalid' | 'focus';
/**
* The type of the button. Only used when an `onclick` or `button` property is present. Possible values are: `"submit"`, `"reset"` and `"button"`. Default value is: `"button"`
*/
'type': 'submit' | 'reset' | 'button';
}
}

Expand Down Expand Up @@ -3358,6 +3362,10 @@ declare global {
*/
'routerDirection'?: RouterDirection;
'state'?: 'valid' | 'invalid' | 'focus';
/**
* The type of the button. Only used when an `onclick` or `button` property is present. Possible values are: `"submit"`, `"reset"` and `"button"`. Default value is: `"button"`
*/
'type'?: 'submit' | 'reset' | 'button';
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions core/src/components/item/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,22 @@ export class Item {
*/
@Prop() lines?: 'full' | 'inset' | 'none';

// TODO document this
@Prop() state?: 'valid' | 'invalid' | 'focus';

/**
* When using a router, it specifies the transition direction when navigating to
* another page using `href`.
*/
@Prop() routerDirection?: RouterDirection;

// TODO document this
@Prop() state?: 'valid' | 'invalid' | 'focus';

/**
* The type of the button. Only used when an `onclick` or `button` property is present.
* Possible values are: `"submit"`, `"reset"` and `"button"`.
* Default value is: `"button"`
*/
@Prop() type: 'submit' | 'reset' | 'button' = 'button';


@Listen('ionStyle')
itemStyle(ev: UIEvent) {
Expand Down Expand Up @@ -131,11 +138,11 @@ export class Item {
}

render() {
const { href, detail, mode, win, state, detailIcon, el, routerDirection } = this;
const { href, detail, mode, win, state, detailIcon, el, routerDirection, type } = this;

const clickable = this.isClickable();
const TagType = clickable ? (href ? 'a' : 'button') : 'div';
const attrs = TagType === 'button' ? { type: 'button' } : { href };
const attrs = TagType === 'button' ? { type: type } : { href };
const showDetail = detail != null ? detail : mode === 'ios' && clickable;

return (
Expand Down
4 changes: 4 additions & 0 deletions core/src/components/item/test/buttons/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<ion-label>button[ion-item]</ion-label>
</ion-item>

<ion-item button type="submit" id="attachClick">
<ion-label>button[ion-item] type="submit"</ion-label>
</ion-item>

<ion-item class="activated" onClick="testClick(event)">
<ion-label>button[ion-item].activated</ion-label>
</ion-item>
Expand Down

0 comments on commit 5f8b02e

Please sign in to comment.