Skip to content

Commit

Permalink
fix(action-sheet): fix action sheet so it will scroll when the option…
Browse files Browse the repository at this point in the history
…s exceed the screen (#13049)

* fix(action-sheet): add ability to scroll buttons in an action sheet

* fix(action-sheet): add scroll to buttons for all modes

* fix(select): add support for more than 6 options in action-sheet

* style(sass): fix linter error

* fix(action-sheet): add flex-shrink to all modes and fix border bleed

also adds variables for md and wp mode padding and removes unused
$action-sheet-md-group-margin-bottom var

* style(sass): fix linter errors

* refactor(action-sheet): remove duplicated overflow styles

* fix(action-sheet): get scroll working properly without cancel button

* fix(action-sheet): remove pointer events from wrapper
  • Loading branch information
brandyscarney authored and manucorporat committed Oct 6, 2017
1 parent 9bfd286 commit 199cb00
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/components/action-sheet/action-sheet-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ViewController } from '../../navigation/view-controller';
'{{b.text}}' +
'</button>' +
'</div>' +
'<div class="action-sheet-group" *ngIf="cancelButton">' +
'<div class="action-sheet-group action-sheet-group-cancel" *ngIf="cancelButton">' +
'<button ion-button="action-sheet-button" (click)="click(cancelButton)" class="action-sheet-cancel disable-hover" [attr.icon-start]="cancelButton.icon ? \'\' : null" [ngClass]="cancelButton.cssClass">' +
'<ion-icon [name]="cancelButton.icon" *ngIf="cancelButton.icon" class="action-sheet-icon"></ion-icon>' +
'{{cancelButton.text}}' +
Expand Down
16 changes: 13 additions & 3 deletions src/components/action-sheet/action-sheet.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ $action-sheet-ios-padding-bottom: $action-sheet-ios-paddin
/// @prop - Padding start of the action sheet
$action-sheet-ios-padding-start: $action-sheet-ios-padding-end !default;

/// @prop - Top margin of the action sheet button group
$action-sheet-ios-group-margin-top: 10px !default;

/// @prop - Bottom margin of the action sheet button group
$action-sheet-ios-group-margin-bottom: 10px !default;

Expand Down Expand Up @@ -90,7 +93,7 @@ $action-sheet-ios-button-cancel-font-weight: 600 !default;
}

.action-sheet-ios .action-sheet-wrapper {
@include margin(auto, auto, constant(safe-area-inset-bottom), auto);
@include margin(constant(safe-area-inset-top), auto, constant(safe-area-inset-bottom), auto);
}

.action-sheet-ios .action-sheet-container {
Expand All @@ -103,9 +106,16 @@ $action-sheet-ios-button-cancel-font-weight: 600 !default;
@include border-radius($action-sheet-ios-border-radius);
@include margin(null, null, $action-sheet-ios-group-margin-bottom - 2, null);

overflow: hidden;

background: $action-sheet-ios-background;

// scss-lint:disable VendorPrefix
-webkit-overflow-scrolling: touch;
// Prevents borders from going outside of the container
-webkit-mask-image: -webkit-radial-gradient(circle, #fff, #000);
}

.action-sheet-ios .action-sheet-group:first-child {
@include margin($action-sheet-ios-group-margin-top, null, null, null);
}

.action-sheet-ios .action-sheet-group:last-child {
Expand Down
22 changes: 14 additions & 8 deletions src/components/action-sheet/action-sheet.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ $action-sheet-md-text-align: start !default;
/// @prop - Background color of the action sheet
$action-sheet-md-background: #fafafa !default;

/// @prop - Bottom margin of the action sheet button group
$action-sheet-md-group-margin-bottom: 8px !default;
/// @prop - Padding top of the action sheet
$action-sheet-md-padding-top: .8rem !default;

/// @prop - Padding bottom of the action sheet
$action-sheet-md-padding-bottom: .8rem !default;

/// @prop - Color of the action sheet title
$action-sheet-md-title-color: #757575 !default;
Expand Down Expand Up @@ -90,11 +93,6 @@ $action-sheet-md-icon-margin-bottom: 0 !default;
/// @prop - Margin start of the icon in the action sheet button
$action-sheet-md-icon-margin-start: 0 !default;

.action-sheet-md .action-sheet-container {
@include padding(.8rem, 0);

background: $action-sheet-md-background;
}

.action-sheet-md .action-sheet-title {
@include text-align($action-sheet-md-text-align);
Expand Down Expand Up @@ -144,7 +142,15 @@ $action-sheet-md-icon-margin-start: 0 !default;
}

.action-sheet-md .action-sheet-group {
overflow: hidden;
background: $action-sheet-md-background;
}

.action-sheet-md .action-sheet-group:first-child {
@include padding($action-sheet-md-padding-top, null, null, null);
}

.action-sheet-md .action-sheet-group:last-child {
@include padding(null, null, $action-sheet-md-padding-bottom, null);
}

.action-sheet-md .action-sheet-group .button-inner {
Expand Down
29 changes: 28 additions & 1 deletion src/components/action-sheet/action-sheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ion-action-sheet {
}

.action-sheet-wrapper {
@include position(null, 0, 0, 0);
@include position(0, 0, 0, 0);
@include margin(auto);
@include transform(translate3d(0, 100%, 0));

Expand All @@ -32,8 +32,35 @@ ion-action-sheet {

width: $action-sheet-width;
max-width: $action-sheet-max-width;

pointer-events: none;
}

.action-sheet-button {
width: $action-sheet-width;
}

.action-sheet-container {
display: flex;

flex-flow: column;

justify-content: flex-end;

height: 100%;
max-height: 100%;
}

.action-sheet-group {
overflow: scroll;

flex-shrink: 2;

pointer-events: all;
}

.action-sheet-group-cancel {
overflow: hidden;

flex-shrink: 0;
}
18 changes: 15 additions & 3 deletions src/components/action-sheet/action-sheet.wp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ $action-sheet-wp-text-align: start !default;
/// @prop - Background color of the action sheet
$action-sheet-wp-background: #fff !default;

/// @prop - Padding top of the action sheet
$action-sheet-wp-padding-top: .8rem !default;

/// @prop - Padding bottom of the action sheet
$action-sheet-wp-padding-bottom: .8rem !default;

/// @prop - Box shadow color of the action sheet
$action-sheet-wp-box-shadow-color: rgba(0, 0, 0, .2) !default;

Expand Down Expand Up @@ -147,12 +153,18 @@ $action-sheet-wp-icon-margin-start: 0 !default;
}
}

.action-sheet-wp .action-sheet-container {
@include padding(.8rem, 0);

.action-sheet-wp .action-sheet-group {
background: $action-sheet-wp-background;
}

.action-sheet-wp .action-sheet-group:first-child {
@include padding($action-sheet-wp-padding-top, null, null, null);
}

.action-sheet-wp .action-sheet-group:last-child {
@include padding(null, null, $action-sheet-wp-padding-bottom, null);
}

.action-sheet-wp .action-sheet-group .button-inner {
justify-content: flex-start;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@

<ion-content padding>

<button ion-button block class="e2eOpenActionSheet" (click)="presentActionSheet1()">Present Action Sheet 1</button>
<button ion-button block (click)="presentActionSheet2()">Present Action Sheet 2</button>
<button ion-button block (click)="presentActionSheet3()">Present Action Sheet 3</button>
<button ion-button block class="e2eOpenActionSheet" (click)="presentBasic()">Basic</button>
<button ion-button block (click)="presentNoBackdropDismiss()">No Backdrop Dismiss</button>
<button ion-button block (click)="presentAlert()">Alert from Action Sheet</button>
<button ion-button block (click)="presentScroll()">Scrollable Options</button>
<button ion-button block (click)="presentScrollNoCancel()">Scroll Without Cancel</button>
<button ion-button block (click)="presentCancelOnly()">Cancel Only</button>

<pre>
Result: {{result}}
Expand Down
170 changes: 167 additions & 3 deletions src/components/action-sheet/test/basic/pages/page-one/page-one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class PageOne {

constructor(public actionSheetCtrl: ActionSheetController, public alertCtrl: AlertController, public modalCtrl: ModalController, public plt: Platform) {}

presentActionSheet1() {
presentBasic() {
this.result = '';

this.actionSheetCtrl.create()
Expand Down Expand Up @@ -66,7 +66,7 @@ export class PageOne {
.present();
}

presentActionSheet2() {
presentNoBackdropDismiss() {
this.result = '';

let actionSheet = this.actionSheetCtrl.create({
Expand Down Expand Up @@ -102,7 +102,7 @@ export class PageOne {
actionSheet.present(actionSheet);
}

presentActionSheet3() {
presentAlert() {
this.result = '';

let actionSheet = this.actionSheetCtrl.create({
Expand Down Expand Up @@ -150,4 +150,168 @@ export class PageOne {
actionSheet.present();
}

presentScroll() {
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Add Reaction',
handler: () => {
console.log('Add Reaction clicked');
}
}, {
text: 'Copy Text',
handler: () => {
console.log('Copy Text clicked');
}
}, {
text: 'Share Text',
handler: () => {
console.log('Share Text clicked');
}
}, {
text: 'Copy Link to Message',
handler: () => {
console.log('Copy Link to Message clicked');
}
}, {
text: 'Remind Me',
handler: () => {
console.log('Remind Me clicked');
}
}, {
text: 'Pin File',
handler: () => {
console.log('Pin File clicked');
}
}, {
text: 'Star File',
handler: () => {
console.log('Star File clicked');
}
}, {
text: 'Mark Unread',
handler: () => {
console.log('Mark Unread clicked');
}
}, {
text: 'Edit Title',
handler: () => {
console.log('Edit Title clicked');
}
}, {
text: 'Save Image',
handler: () => {
console.log('Save Image clicked');
}
}, {
text: 'Copy Image',
handler: () => {
console.log('Copy Image clicked');
}
}, {
text: 'Delete File',
role: 'destructive',
handler: () => {
console.log('Delete File clicked');
}
}, {
text: 'Cancel',
role: 'cancel', // will always sort to be on the bottom
handler: () => {
console.log('Cancel clicked');
}
}
]
});

actionSheet.present();
}

presentScrollNoCancel() {
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Add Reaction',
handler: () => {
console.log('Add Reaction clicked');
}
}, {
text: 'Copy Text',
handler: () => {
console.log('Copy Text clicked');
}
}, {
text: 'Share Text',
handler: () => {
console.log('Share Text clicked');
}
}, {
text: 'Copy Link to Message',
handler: () => {
console.log('Copy Link to Message clicked');
}
}, {
text: 'Remind Me',
handler: () => {
console.log('Remind Me clicked');
}
}, {
text: 'Pin File',
handler: () => {
console.log('Pin File clicked');
}
}, {
text: 'Star File',
handler: () => {
console.log('Star File clicked');
}
}, {
text: 'Mark Unread',
handler: () => {
console.log('Mark Unread clicked');
}
}, {
text: 'Edit Title',
handler: () => {
console.log('Edit Title clicked');
}
}, {
text: 'Save Image',
handler: () => {
console.log('Save Image clicked');
}
}, {
text: 'Copy Image',
handler: () => {
console.log('Copy Image clicked');
}
}, {
text: 'Delete File',
role: 'destructive',
handler: () => {
console.log('Delete File clicked');
}
}
]
});

actionSheet.present();
}

presentCancelOnly() {
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Cancel',
role: 'cancel', // will always sort to be on the bottom
handler: () => {
console.log('Cancel clicked');
}
}
]
});

actionSheet.present();
}

}
4 changes: 0 additions & 4 deletions src/components/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,6 @@ export class Select extends BaseInput<any> implements OnDestroy {
}

let options = this._options.toArray();
if (this.interface === 'action-sheet' && options.length > 6) {
console.warn('Interface cannot be "action-sheet" with more than 6 options. Using the "alert" interface.');
this.interface = 'alert';
}

if ((this.interface === 'action-sheet' || this.interface === 'popover') && this._multi) {
console.warn('Interface cannot be "' + this.interface + '" with a multi-value select. Using the "alert" interface.');
Expand Down
Loading

0 comments on commit 199cb00

Please sign in to comment.