@@ -9,6 +9,8 @@ import { Button } from "../ui/button";
99import { Textarea } from "../ui/textarea" ;
1010import { toastManager } from "../ui/toast" ;
1111import { PullRequestGlyph } from "./pullRequestIcons" ;
12+ import { pullRequestReviewKey } from "./pullRequestReviewStore" ;
13+ import { useInlineActionConfirm } from "./useInlineActionConfirm" ;
1214
1315export function PullRequestCommentForm ( {
1416 environmentId,
@@ -37,6 +39,7 @@ export function PullRequestCommentForm({
3739 const postComment = useAtomCommand ( pullRequestEnvironment . comment , {
3840 reportFailure : false ,
3941 } ) ;
42+ const inlineConfirm = useInlineActionConfirm ( pullRequestReviewKey ( reference ) ) ;
4043 const followUpAction =
4144 detail . state === "open" &&
4245 detail . capabilities . actions . includes ( "close" ) &&
@@ -111,20 +114,34 @@ export function PullRequestCommentForm({
111114 size = "xs"
112115 variant = { followUpAction === "close" ? "destructive-outline" : "outline" }
113116 disabled = { body . trim ( ) . length === 0 || submitting !== null || actionPending }
114- onClick = { ( ) => void submit ( followUpAction ) }
117+ { ...( followUpAction === "close"
118+ ? inlineConfirm . props ( "close" , ( ) => void submit ( "close" ) )
119+ : { onClick : ( ) => void submit ( "reopen" ) } ) }
115120 >
116121 { followUpAction === "close" ? (
117122 < PullRequestGlyph . closed className = "size-3.5" />
118123 ) : (
119124 < PullRequestGlyph . reopen className = "size-3.5" />
120125 ) }
121- { submitting === followUpAction
122- ? followUpAction === "close"
123- ? "Closing..."
124- : "Reopening..."
125- : followUpAction === "close"
126- ? "Close with comment"
127- : "Reopen with comment" }
126+ { followUpAction === "close" ? (
127+ // The longest label holds the width, so the confirming click lands on the button.
128+ < span className = "inline-grid" >
129+ < span aria-hidden className = "invisible col-start-1 row-start-1" >
130+ Close with comment
131+ </ span >
132+ < span className = "col-start-1 row-start-1" >
133+ { submitting === "close"
134+ ? "Closing..."
135+ : inlineConfirm . isArmed ( "close" )
136+ ? "Confirm close?"
137+ : "Close with comment" }
138+ </ span >
139+ </ span >
140+ ) : submitting === "reopen" ? (
141+ "Reopening..."
142+ ) : (
143+ "Reopen with comment"
144+ ) }
128145 </ Button >
129146 ) }
130147 < Button
0 commit comments