Skip to content

Commit

Permalink
fix: linting issues (#472)
Browse files Browse the repository at this point in the history
* fixed ChatBody linting error
added scrollToBottom in EmbeddedChat

* disabled eslint label explicit associated control

changed message to msg to avoid conflict

* fixed touch timer undeclared var

* fixed linting issue in ModalBackDrop

* fixed linting issue in Modal.js

* temporary disabled linting error in UiKitModal
  • Loading branch information
Spiral-Memory authored Feb 17, 2024
1 parent cbec05e commit 33c160d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 35 deletions.
10 changes: 5 additions & 5 deletions packages/react/src/components/ChatBody/ChatBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const ChatBody = ({
}
`;

const [scrollPosition, setScrollPosition] = useState(0);
const [popupVisible, setPopupVisible] = useState(false);
const [, setIsUserScrolledUp] = useState(false);
const [otherUserMessage, setOtherUserMessage] = useState(false);

const { RCInstance, ECOptions } = useContext(RCContext);
const messages = useMessageStore((state) => state.messages);
const threadMessages = useMessageStore((state) => state.threadMessages);
Expand Down Expand Up @@ -173,11 +178,6 @@ const ChatBody = ({
anonymousMode,
]);

const [scrollPosition, setScrollPosition] = useState(0);
const [popupVisible, setPopupVisible] = useState(false);
const [isUserScrolledUp, setIsUserScrolledUp] = useState(false);
const [otherUserMessage, setOtherUserMessage] = useState(false);

const handlePopupClick = () => {
scrollToBottom();
setIsUserScrolledUp(false);
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/CheckBox/CheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const CheckBox = ({ checked, ...props }) => {
}
`;
return (
// eslint-disable-next-line jsx-a11y/label-has-associated-control
<label
css={CheckBoxCss}
className={appendClassNames('ec-check-box', classNames)}
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/components/EmbeddedChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ const EmbeddedChat = ({
anonymousMode={anonymousMode}
showRoles={showRoles}
messageListRef={messageListRef}
scrollToBottom={scrollToBottom}
/>
) : (
<Home height={!fullScreen ? height : '88vh'} />
Expand All @@ -266,6 +267,7 @@ const EmbeddedChat = ({
anonymousMode={anonymousMode}
showRoles={showRoles}
messageListRef={messageListRef}
scrollToBottom={scrollToBottom}
/>
) : (
<Home height={!fullScreen ? height : '88vh'} />
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Message/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ const Message = ({
}
};

const handleDeleteMessage = async (message) => {
const res = await RCInstance.deleteMessage(message._id);
const handleDeleteMessage = async (msg) => {
const res = await RCInstance.deleteMessage(msg._id);

if (res.success) {
dispatchToastMessage({
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/components/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ export const Modal = forwardRef(
background: ${theme?.palette?.background?.modal || '#fff'};
border-radius: 0.25rem;
`;
if (!open) {
return null;
}

const handleClick = useCallback(
(e) => {
Expand Down Expand Up @@ -63,6 +60,10 @@ export const Modal = forwardRef(
};
}, [handleEscKey]);

if (!open) {
return null;
}

return (
<ModalBackdrop ref={backDropRef} onClick={handleClick}>
<Box
Expand Down
46 changes: 23 additions & 23 deletions packages/react/src/components/Modal/ModalBackdrop.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import React, { forwardRef } from 'react';
import { Box } from '../Box';

export const ModalBackdrop = forwardRef(
({ children, onClick = () => {} }, ref) => (
<Box
ref={ref}
onClick={onClick}
style={{
position: 'fixed',
zIndex: 10000,
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: '#333333B3',
width: '100%',
height: '100%',
}}
>
{children}
</Box>
)
);
const ModalBackdrop = forwardRef(({ children, onClick = () => {} }, ref) => (
<Box
ref={ref}
onClick={onClick}
style={{
position: 'fixed',
zIndex: 10000,
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: '#333333B3',
width: '100%',
height: '100%',
}}
>
{children}
</Box>
));
ModalBackdrop.displayName = 'ModalBackdrop';
export { ModalBackdrop };
4 changes: 2 additions & 2 deletions packages/react/src/components/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const Tooltip = ({ children, text, position }) => {
setTooltipVisible(false);
};

let touchTimer;

const handleTouchStart = () => {
touchTimer = setTimeout(() => {
setTooltipVisible(true);
Expand All @@ -59,8 +61,6 @@ const Tooltip = ({ children, text, position }) => {
setTooltipVisible(false);
};

let touchTimer;

return (
<div
onMouseEnter={handleMouseEnter}
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/components/uiKit/blocks/UiKitModal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable react/jsx-no-undef */
/* eslint-disable import/extensions */
/* eslint-disable import/no-unresolved */
/* eslint-disable no-shadow */
/* eslint-disable react/jsx-no-constructed-context-values */
import React from 'react';
Expand Down

0 comments on commit 33c160d

Please sign in to comment.