Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provides a fix for a bug in Safari where XHR form submission fails wh… #4673

Merged
merged 2 commits into from
Jun 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions admin/client/App/screens/Item/components/EditForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,19 @@ var EditForm = React.createClass({
updateItem () {
const { data, list } = this.props;
const editForm = this.refs.editForm;

// Fix for Safari where XHR form submission fails when input[type=file] is empty
// https://stackoverflow.com/questions/49614091/safari-11-1-ajax-xhr-form-submission-fails-when-inputtype-file-is-empty
$(editForm).find("input[type='file']").each(function () {
if ($(this).get(0).files.length === 0) { $(this).prop('disabled', true); }
});

const formData = new FormData(editForm);

$(editForm).find("input[type='file']").each(function () {
if ($(this).get(0).files.length === 0) { $(this).prop('disabled', false); }
});

// Show loading indicator
this.setState({
loading: true,
Expand Down