Skip to content

Commit

Permalink
pods: Always ignore validation errors for empty slots in PodCreateModal
Browse files Browse the repository at this point in the history
They might show up when the port row is removed before the debounced
validation has actually run.
  • Loading branch information
mvollmer authored and martinpitt committed Oct 18, 2024
1 parent 6f482bc commit 07197e5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/PodCreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,20 @@ export const PodCreateModal = ({ user, systemServiceAvailable, userServiceAvaila
};

const isFormInvalid = validationFailed => {
const groupHasError = row => row && Object.values(row)
.filter(val => val) // Filter out empty/undefined properties
.length > 0; // If one field has error, the whole group (dynamicList) is invalid
function publishGroupHasError(row, idx) {
// We always ignore errors for empty slots in
// publish. Errors for these slots might show up when the
// debounced validation runs after a row has been removed.
if (!row || !publish[idx])
return false;

return Object.values(row)
.filter(val => val) // Filter out empty/undefined properties
.length > 0; // If one field has error, the whole group (dynamicList) is invalid
}

// If at least one group is invalid, then the whole form is invalid
return validationFailed.publish?.some(groupHasError) ||
return validationFailed.publish?.some(publishGroupHasError) ||
!!validationFailed.podName;
};

Expand Down

0 comments on commit 07197e5

Please sign in to comment.