Skip to content

Commit

Permalink
fix(popover): default alignment to 'center' for ios mode (#24815)
Browse files Browse the repository at this point in the history
  • Loading branch information
averyjohnston authored Feb 18, 2022
1 parent 0a8f443 commit 243f673
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ ion-picker,css-prop,--min-width
ion-picker,css-prop,--width

ion-popover,shadow
ion-popover,prop,alignment,"center" | "end" | "start",'start',false,false
ion-popover,prop,alignment,"center" | "end" | "start" | undefined,undefined,false,false
ion-popover,prop,animated,boolean,true,false,false
ion-popover,prop,arrow,boolean,true,false,false
ion-popover,prop,backdropDismiss,boolean,true,false,false
Expand Down
6 changes: 3 additions & 3 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,9 +1848,9 @@ export namespace Components {
}
interface IonPopover {
/**
* Describes how to align the popover content with the `reference` point.
* Describes how to align the popover content with the `reference` point. Defaults to `'center'` for `ios` mode, and `'start'` for `md` mode.
*/
"alignment": PositionAlign;
"alignment"?: PositionAlign;
/**
* If `true`, the popover will animate.
*/
Expand Down Expand Up @@ -5485,7 +5485,7 @@ declare namespace LocalJSX {
}
interface IonPopover {
/**
* Describes how to align the popover content with the `reference` point.
* Describes how to align the popover content with the `reference` point. Defaults to `'center'` for `ios` mode, and `'start'` for `md` mode.
*/
"alignment"?: PositionAlign;
/**
Expand Down
7 changes: 6 additions & 1 deletion core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ export class Popover implements ComponentInterface, PopoverInterface {

/**
* Describes how to align the popover content with the `reference` point.
* Defaults to `'center'` for `ios` mode, and `'start'` for `md` mode.
*/
@Prop() alignment: PositionAlign = 'start';
@Prop({ mutable: true }) alignment?: PositionAlign;

/**
* If `true`, the popover will display an arrow
Expand Down Expand Up @@ -292,6 +293,10 @@ export class Popover implements ComponentInterface, PopoverInterface {
this.popoverId = (this.el.hasAttribute('id')) ? this.el.getAttribute('id')! : `ion-popover-${this.popoverIndex}`;

this.parentPopover = this.el.closest(`ion-popover:not(#${this.popoverId})`) as HTMLIonPopoverElement | null;

if (this.alignment === undefined) {
this.alignment = getIonMode(this) === 'ios' ? 'center' : 'start';
}
}

componentDidLoad() {
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/popover/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ export default {

| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------- |
| `alignment` | `alignment` | Describes how to align the popover content with the `reference` point. | `"center" \| "end" \| "start"` | `'start'` |
| `alignment` | `alignment` | Describes how to align the popover content with the `reference` point. Defaults to `'center'` for `ios` mode, and `'start'` for `md` mode. | `"center" \| "end" \| "start" \| undefined` | `undefined` |
| `animated` | `animated` | If `true`, the popover will animate. | `boolean` | `true` |
| `arrow` | `arrow` | If `true`, the popover will display an arrow that points at the `reference` when running in `ios` mode on mobile. Does not apply in `md` mode or on desktop. | `boolean` | `true` |
| `backdropDismiss` | `backdrop-dismiss` | If `true`, the popover will be dismissed when the backdrop is clicked. | `boolean` | `true` |
Expand Down

0 comments on commit 243f673

Please sign in to comment.