-
Notifications
You must be signed in to change notification settings - Fork 9
Introduce inputModes option for showing score and comment fields #472
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
813522d
ab464b6
d12e742
cd66efc
7096699
4bc9e1f
ebc3bee
f1318f6
e7ab8d8
b1ad633
a27328c
4d0b799
9c6faae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ import { FeedbackForm } from "./FeedbackForm"; | |
| import styles from "./index.css?inline"; | ||
| import { RadialProgress } from "./RadialProgress"; | ||
| import { | ||
| FeedbackScoreSubmission, | ||
| FeedbackSubmission, | ||
| OpenFeedbackFormOptions, | ||
| WithRequired, | ||
|
|
@@ -25,26 +24,19 @@ export type FeedbackDialogProps = WithRequired< | |
| const INACTIVE_DURATION_MS = 20 * 1000; | ||
| const SUCCESS_DURATION_MS = 3 * 1000; | ||
|
|
||
| export type FormState = "idle" | "submitting" | "submitted" | "error"; | ||
|
|
||
| export const FeedbackDialog: FunctionComponent<FeedbackDialogProps> = ({ | ||
| key, | ||
| title = DEFAULT_TRANSLATIONS.DefaultQuestionLabel, | ||
| position, | ||
| translations = DEFAULT_TRANSLATIONS, | ||
| openWithCommentVisible = false, | ||
| requireSatisfactionScore = true, | ||
| inputMode = "comment-and-score", | ||
| onClose, | ||
| onDismiss, | ||
| onSubmit, | ||
| onScoreSubmit, | ||
| }) => { | ||
| // If requireSatisfactionScore is false, always show comment field | ||
| const effectiveOpenWithCommentVisible = | ||
| requireSatisfactionScore === false ? true : openWithCommentVisible; | ||
|
|
||
| const [feedbackId, setFeedbackId] = useState<string | undefined>(undefined); | ||
| const [scoreState, setScoreState] = useState< | ||
| "idle" | "submitting" | "submitted" | ||
| >("idle"); | ||
| const [formState, setFormState] = useState<FormState>("idle"); | ||
|
|
||
| const { isOpen, close } = useDialog({ onClose, initialValue: true }); | ||
|
|
||
|
|
@@ -56,24 +48,21 @@ export const FeedbackDialog: FunctionComponent<FeedbackDialogProps> = ({ | |
|
|
||
| const submit = useCallback( | ||
| async (data: Omit<FeedbackSubmission, "feedbackId">) => { | ||
| await onSubmit({ ...data, feedbackId }); | ||
| autoClose.startWithDuration(SUCCESS_DURATION_MS); | ||
| }, | ||
| [autoClose, feedbackId, onSubmit], | ||
| ); | ||
|
|
||
| const submitScore = useCallback( | ||
| async (data: Omit<FeedbackScoreSubmission, "feedbackId">) => { | ||
| if (onScoreSubmit !== undefined) { | ||
| setScoreState("submitting"); | ||
|
|
||
| const res = await onScoreSubmit({ ...data, feedbackId }); | ||
| setFeedbackId(res.feedbackId); | ||
| setScoreState("submitted"); | ||
| try { | ||
| setFormState("submitting"); | ||
| const res = await onSubmit({ ...data }); | ||
| if (!res) throw new Error("Failed to submit feedback"); | ||
| setFormState("submitted"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Feedback Dialog Fails on Void ReturnThe |
||
| autoClose.startWithDuration(SUCCESS_DURATION_MS); | ||
| } catch (error) { | ||
| setFormState("error"); | ||
| console.error("Couldn't submit feedback with Reflag:", error); | ||
| throw error; | ||
| } | ||
| }, | ||
| [feedbackId, onScoreSubmit], | ||
| [autoClose, onSubmit], | ||
| ); | ||
|
|
||
| const dismiss = useCallback(() => { | ||
| autoClose.stop(); | ||
| close(); | ||
|
|
@@ -94,14 +83,12 @@ export const FeedbackDialog: FunctionComponent<FeedbackDialogProps> = ({ | |
| <> | ||
| <FeedbackForm | ||
| key={key} | ||
| openWithCommentVisible={effectiveOpenWithCommentVisible} | ||
| inputMode={inputMode} | ||
| question={title} | ||
| requireSatisfactionScore={requireSatisfactionScore} | ||
| scoreState={scoreState} | ||
| t={{ ...DEFAULT_TRANSLATIONS, ...translations }} | ||
| onInteraction={autoClose.stop} | ||
| onScoreSubmit={submitScore} | ||
| onSubmit={submit} | ||
| formState={formState} | ||
| /> | ||
|
|
||
| <button class="close" onClick={dismiss}> | ||
|
|
@@ -111,7 +98,7 @@ export const FeedbackDialog: FunctionComponent<FeedbackDialogProps> = ({ | |
| progress={1.0 - autoClose.elapsedFraction} | ||
| /> | ||
| )} | ||
| <Close /> | ||
| <Close width={18} height={18} /> | ||
| </button> | ||
| </> | ||
| </Dialog> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about the background here. My thinking is that if someone submits a comment, we'll eventually be able to deduct the sentiment. So it ends up feeling weird to ever have the comment first and then the satisfaction second? I could imagine the options being:
I know this is late feedback, apologies.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inspiration was Vercel (from the Linear issue):
Wouldn't that be an argument for the opposite? Why have the score first if it can be derived from the comment?
There can also be a value in specifying the score manually like Vercel; either to be clear about intent or if you don't have time to write a comment but still want to give a nod up/down.
In general, we're moving away from a primary satisfaction score towards it being additional/optional. Having two out of three options put score front and center is misleading and not useful IMO.
I don't see much use for the sequential screens anymore and it complicates implementation a lot. IF you're looking to gather a score for a bigger audience (like post GA release), I think a score-only UI is fine? For all other cases, the comment field is preferred