Skip to content

Commit eb2b6ca

Browse files
authored
Merge pull request #1963 from dpalou/MOBILE-3039
MOBILE-3039 ios: Fix 'More' option in file uploader
2 parents 240f425 + cb6a987 commit eb2b6ca

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/app/app.ios.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,17 @@ ion-app.app-root.ios {
9898
border-color: $checkbox-ios-icon-border-color-off;
9999
background-color: $checkbox-ios-background-color-off;
100100
}
101+
102+
// File Uploader
103+
// In iOS the input is 1 level higher, so the styles are different.
104+
.action-sheet-ios input.core-fileuploader-file-handler-input {
105+
position: absolute;
106+
@include position(null, 0, null, 0);
107+
min-width: 100%;
108+
min-height: $action-sheet-ios-button-min-height;
109+
opacity: 0;
110+
outline: none;
111+
z-index: 100;
112+
cursor: pointer;
113+
}
101114
}

src/core/fileuploader/providers/file-handler.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
7171
if (element) {
7272
const input = document.createElement('input');
7373
input.setAttribute('type', 'file');
74+
input.classList.add('core-fileuploader-file-handler-input');
7475
if (mimetypes && mimetypes.length && (!this.platform.is('android') || mimetypes.length == 1)) {
7576
// Don't use accept attribute in Android with several mimetypes, it's not supported.
7677
input.setAttribute('accept', mimetypes.join(', '));
@@ -112,7 +113,22 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
112113
});
113114
});
114115

115-
element.appendChild(input);
116+
if (this.platform.is('ios')) {
117+
// In iOS, the click on the input stopped working for some reason. We need to put it 1 level higher.
118+
element.parentElement.appendChild(input);
119+
120+
// Animate the button when the input is clicked.
121+
input.addEventListener('mousedown', () => {
122+
element.classList.add('activated');
123+
});
124+
input.addEventListener('mouseup', () => {
125+
this.platform.timeout(() => {
126+
element.classList.remove('activated');
127+
}, 80);
128+
});
129+
} else {
130+
element.appendChild(input);
131+
}
116132
}
117133
}
118134
};

0 commit comments

Comments
 (0)