Skip to content

Commit

Permalink
fix(autofix): Fix issues with feedback button in autofix drawer (#79169)
Browse files Browse the repository at this point in the history
Fixes a couple issues:

- The feedback dialog would close whenever useAutofix polled for new
data
- Interacting with the feedback dialog would close the drawer
  • Loading branch information
malwilley authored Oct 16, 2024
1 parent 54c3a42 commit 443dbc9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
5 changes: 4 additions & 1 deletion static/app/components/events/autofix/autofixBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function SuccessfulSetup({
// we don't reopen it immediately, and instead let the button handle this itself.
shouldCloseOnInteractOutside: element => {
const viewAllButton = openButtonRef.current;
if (viewAllButton?.contains(element)) {
if (
viewAllButton?.contains(element) ||
document.getElementById('sentry-feedback')?.contains(element)
) {
return false;
}
return true;
Expand Down
30 changes: 17 additions & 13 deletions static/app/components/events/autofix/autofixFeedback.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
import {useRef} from 'react';

import {Button} from 'sentry/components/button';
import useFeedbackWidget from 'sentry/components/feedback/widget/useFeedbackWidget';
import {IconMegaphone} from 'sentry/icons/iconMegaphone';
import {t} from 'sentry/locale';
import {useFeedbackForm} from 'sentry/utils/useFeedbackForm';

function AutofixFeedback() {
const buttonRef = useRef<HTMLButtonElement>(null);
const feedback = useFeedbackWidget({
buttonRef,
messagePlaceholder: t('How can we make Autofix better for you?'),
optionOverrides: {
tags: {
['feedback.source']: 'issue_details_ai_autofix',
['feedback.owner']: 'ml-ai',
},
},
});
const openForm = useFeedbackForm();

if (!feedback) {
if (!openForm) {
return null;
}

return (
<Button ref={buttonRef} size="xs" icon={<IconMegaphone />}>
<Button
ref={buttonRef}
size="xs"
icon={<IconMegaphone />}
onClick={() =>
openForm({
messagePlaceholder: t('How can we make Autofix better for you?'),
tags: {
['feedback.source']: 'issue_details_ai_autofix',
['feedback.owner']: 'ml-ai',
},
})
}
>
{t('Give Feedback')}
</Button>
);
Expand Down
8 changes: 4 additions & 4 deletions static/app/views/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,16 @@ function App({children, params}: Props) {
<RouteAnalyticsContextProvider>
<OrganizationContextProvider>
<AsyncSDKIntegrationContextProvider>
<GlobalDrawer>
<GlobalFeedbackForm>
<GlobalFeedbackForm>
<GlobalDrawer>
<MainContainer tabIndex={-1} ref={mainContainerRef}>
<GlobalModal onClose={handleModalClose} />
<SystemAlerts className="messages-container" />
<Indicators className="indicators-container" />
<ErrorBoundary>{renderBody()}</ErrorBoundary>
</MainContainer>
</GlobalFeedbackForm>
</GlobalDrawer>
</GlobalDrawer>
</GlobalFeedbackForm>
</AsyncSDKIntegrationContextProvider>
</OrganizationContextProvider>
</RouteAnalyticsContextProvider>
Expand Down

0 comments on commit 443dbc9

Please sign in to comment.