Skip to content

Commit 99f72f5

Browse files
committed
A few tweaks
1 parent fda2568 commit 99f72f5

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

packages/component/src/Activity/ActivityFeedback.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { hooks } from 'botframework-webchat-api';
22
import { getOrgSchemaMessage, OrgSchemaAction, parseAction, WebChatActivity } from 'botframework-webchat-core';
33
import classNames from 'classnames';
44
import React, { memo, useCallback, useMemo, useState } from 'react';
5+
import { useRefFrom } from 'use-ref-from';
6+
57
import useStyleSet from '../hooks/useStyleSet';
68
import dereferenceBlankNodes from '../Utils/JSONLinkedData/dereferenceBlankNodes';
79
import Feedback from './private/Feedback';
10+
import FeedbackForm from './private/FeedbackForm';
811
import getDisclaimer from './private/getDisclaimer';
912
import hasFeedbackLoop from './private/hasFeedbackLoop';
10-
import FeedbackForm from './private/FeedbackForm';
1113

1214
const { useStyleOptions } = hooks;
1315

@@ -47,6 +49,7 @@ function ActivityFeedback({ activity }: ActivityFeedbackProps) {
4749

4850
const [selectedAction, setSelectedAction] = useState<OrgSchemaAction | undefined>();
4951
const [feedbackSubmitted, setFeedbackSubmitted] = useState<boolean>(false);
52+
const selectedActionRef = useRefFrom(selectedAction);
5053

5154
const isFeedbackLoopSupported = hasFeedbackLoop(activity);
5255

@@ -62,14 +65,13 @@ function ActivityFeedback({ activity }: ActivityFeedbackProps) {
6265
try {
6366
const reactActions = (messageThing?.potentialAction || [])
6467
.filter(({ '@type': type }) => type === 'LikeAction' || type === 'DislikeAction')
65-
.map(action =>
66-
Object.assign({}, action, {
67-
actionStatus:
68-
action['@type'] === selectedAction?.['@type'] && feedbackSubmitted
69-
? 'CompletedActionStatus'
70-
: action.actionStatus
71-
})
72-
);
68+
.map(action => ({
69+
...action,
70+
actionStatus:
71+
action['@type'] === selectedActionRef.current?.['@type'] && feedbackSubmitted
72+
? 'CompletedActionStatus'
73+
: action.actionStatus
74+
}));
7375

7476
if (reactActions.length) {
7577
return Object.freeze(new Set(reactActions));
@@ -84,9 +86,7 @@ function ActivityFeedback({ activity }: ActivityFeedbackProps) {
8486
// Intentionally left blank.
8587
}
8688
return Object.freeze(new Set([] as OrgSchemaAction[]));
87-
// Do not want to add selectedAction to the dependency array as it will cause an infinite loop
88-
// eslint-disable-next-line react-hooks/exhaustive-deps
89-
}, [feedbackSubmitted, graph, messageThing?.potentialAction]);
89+
}, [feedbackSubmitted, graph, messageThing, selectedActionRef]);
9090

9191
const handleFeedbackActionClick = useCallback(
9292
(action: OrgSchemaAction) => setSelectedAction(action === selectedAction ? undefined : action),

packages/component/src/Activity/private/FeedbackForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React, { memo, useCallback, useEffect, useRef, useState, type FormEventHandler } from 'react';
21
import { hooks } from 'botframework-webchat-api';
32
import classNames from 'classnames';
4-
import FeedbackFormDisclaimer from './FeedbackFormDisclaimer';
3+
import React, { memo, useCallback, useEffect, useRef, useState, type FormEventHandler } from 'react';
54
import { useRefFrom } from 'use-ref-from';
5+
66
import useStyleSet from '../../hooks/useStyleSet';
77
import testIds from '../../testIds';
8+
import FeedbackFormDisclaimer from './FeedbackFormDisclaimer';
89
import TextArea from './FeedbackTextArea';
910

1011
const { useLocalizer, usePostActivity } = hooks;

packages/component/src/Styles/StyleSet/ThumbButton.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ export default function () {
3434
background: 'transparent',
3535
color: CSSTokens.ColorAccent
3636
},
37+
3738
'&[aria-disabled="true"]': {
38-
color: CSSTokens.ColorSubtle,
39-
'&:not(.webchat__thumb-button--is-pressed) > .webchat__tooltip': {
40-
display: 'none'
41-
}
39+
color: CSSTokens.ColorSubtle
40+
},
41+
42+
'&.webchat__thumb-button--submitted:not(.webchat__thumb-button--is-pressed) .webchat__tooltip': {
43+
display: 'none'
4244
}
4345
},
4446

0 commit comments

Comments
 (0)