Skip to content

fix(feedback): Send feedback rejects invalid responses #12518

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

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 10 additions & 8 deletions packages/feedback/src/core/sendFeedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ export const sendFeedback: SendFeedback = (
if (
response &&
typeof response.statusCode === 'number' &&
(response.statusCode < 200 || response.statusCode >= 300)
response.statusCode >= 200 &&
response.statusCode < 300
) {
if (response.statusCode === 0) {
return reject(
'Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.',
);
}
return reject('Unable to send Feedback. Invalid response from server.');
resolve(eventId);
}

resolve(eventId);
if (response && typeof response.statusCode === 'number' && response.statusCode === 0) {
return reject(
'Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.',
);
}

return reject('Unable to send Feedback. Invalid response from server.');
});
});
};
Expand Down
3 changes: 2 additions & 1 deletion packages/feedback/src/modal/components/Dialog.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ const FORM = `
}

.form__right {
min-width: var(--form-width, 272px);
flex: 0 0 var(--form-width, 272px);
width: var(--form-width, 272px);
display: flex;
overflow: auto;
flex-direction: column;
Expand Down
8 changes: 6 additions & 2 deletions packages/feedback/src/modal/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function Form({
onSubmitSuccess(data);
} catch (error) {
DEBUG_BUILD && logger.error(error);
setError('There was a problem submitting feedback, please wait and try again.');
setError(error as string);
onSubmitError(error as Error);
}
} catch {
Expand Down Expand Up @@ -228,7 +228,11 @@ function LabelText({
label,
isRequired,
isRequiredLabel,
}: { label: string; isRequired: boolean; isRequiredLabel: string }): VNode {
}: {
label: string;
isRequired: boolean;
isRequiredLabel: string;
}): VNode {
return (
<span class="form__label__text">
{label}
Expand Down
Loading