Skip to content

Commit

Permalink
Fix forwardRef warnings
Browse files Browse the repository at this point in the history
* `Sign Up` button
* comment boxes
* actionsForm.js (mostly buttons)

Signed-off-by: Taylor Smock <tsmock@meta.com>
  • Loading branch information
tsmock committed May 31, 2023
1 parent ab71463 commit dd5d203
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 42 deletions.
38 changes: 17 additions & 21 deletions frontend/src/components/comments/commentInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useRef, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import MDEditor from '@uiw/react-md-editor';
import Tribute from 'tributejs';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, useIntl } from 'react-intl';
import { useDropzone } from 'react-dropzone';

import 'tributejs/tribute.css';
Expand Down Expand Up @@ -109,26 +109,22 @@ export const CommentInputField = ({
</div>
)}
<div className={`${isShowPreview ? 'dn' : ''} bg-white`} data-color-mode="light">
<FormattedMessage {...placeholderMsg}>
{(val) => (
<MDEditor
ref={textareaRef}
preview="edit"
commands={Object.keys(iconConfig).map((key) => iconConfig[key])}
extraCommands={[]}
height={200}
value={comment}
onChange={setComment}
textareaProps={{
...getInputProps(),
spellCheck: 'true',
placeholder: val,
...markdownTextareaProps,
}}
defaultTabEnable
/>
)}
</FormattedMessage>
<MDEditor
ref={textareaRef}
preview="edit"
commands={Object.keys(iconConfig).map((key) => iconConfig[key])}
extraCommands={[]}
height={200}
value={comment}
onChange={setComment}
textareaProps={{
...getInputProps(),
spellCheck: 'true',
placeholder: useIntl().formatMessage(placeholderMsg),
...markdownTextareaProps,
}}
defaultTabEnable
/>
<input
type="file"
id="image_picker"
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/deleteModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { DeleteButton } from '../teamsAndOrgs/management';
import { Button } from '../button';
import { AlertIcon } from '../svgIcons';

const DeleteTrigger = React.forwardRef((props, ref) => <DeleteButton {...props} />);

export function DeleteModal({ id, name, type, className }: Object) {
const navigate = useNavigate();
const token = useSelector((state) => state.auth.token);
Expand All @@ -35,7 +37,7 @@ export function DeleteModal({ id, name, type, className }: Object) {

return (
<Popup
trigger={<DeleteButton className={`${className || ''} dib ml3`} />}
trigger={<DeleteTrigger className={`${className || ''} dib ml3`} />}
modal
closeOnDocumentClick
onClose={() => {
Expand Down
23 changes: 15 additions & 8 deletions frontend/src/components/header/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useRef } from 'react';
import React, { Fragment, useRef, forwardRef } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { Link, useNavigate, useLocation } from 'react-router-dom';
import Popup from 'reactjs-popup';
Expand Down Expand Up @@ -208,6 +208,19 @@ const UserDisplay = ({ username }) => {
);
};

const SignupTrigger = forwardRef((props, ref) => {
const { signUpStyle, alternativeSignUpText, ...remainingProps } = props;
return (
<Button className={signUpStyle} {...remainingProps}>
{alternativeSignUpText ? (
<FormattedMessage {...messages.createAccount} />
) : (
<FormattedMessage {...messages.signUp} />
)}
</Button>
);
});

export const AuthButtons = ({
logInStyle,
signUpStyle,
Expand All @@ -227,13 +240,7 @@ export const AuthButtons = ({
</Button>
<Popup
trigger={
<Button className={signUpStyle}>
{alternativeSignUpText ? (
<FormattedMessage {...messages.createAccount} />
) : (
<FormattedMessage {...messages.signUp} />
)}
</Button>
<SignupTrigger signUpStyle={signUpStyle} alternativeSignUpText={alternativeSignUpText} />
}
modal
closeOnDocumentClick
Expand Down
28 changes: 16 additions & 12 deletions frontend/src/components/projectEdit/actionsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ const TransferProject = ({ projectId, orgId }: Object) => {
);
};

const FormattedButtonTrigger = React.forwardRef((props, ref) => (
<Button {...props}>{props.children}</Button>
));

export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
const navigate = useNavigate();

Expand All @@ -502,9 +506,9 @@ export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
</label>
<Popup
trigger={
<Button className={styleClasses.actionClass}>
<FormattedButtonTrigger className={styleClasses.actionClass}>
<FormattedMessage {...messages.messageContributors} />
</Button>
</FormattedButtonTrigger>
}
modal
closeOnDocumentClick
Expand All @@ -528,9 +532,9 @@ export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
</p>
<Popup
trigger={
<Button className={styleClasses.actionClass}>
<FormattedButtonTrigger className={styleClasses.actionClass}>
<FormattedMessage {...messages.mapAll} />
</Button>
</FormattedButtonTrigger>
}
modal
closeOnDocumentClick
Expand All @@ -539,9 +543,9 @@ export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
</Popup>
<Popup
trigger={
<Button className={styleClasses.actionClass}>
<FormattedButtonTrigger className={styleClasses.actionClass}>
<FormattedMessage {...messages.invalidateAll} />
</Button>
</FormattedButtonTrigger>
}
modal
closeOnDocumentClick
Expand All @@ -550,9 +554,9 @@ export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
</Popup>
<Popup
trigger={
<Button className={styleClasses.actionClass}>
<FormattedButtonTrigger className={styleClasses.actionClass}>
<FormattedMessage {...messages.validateAllTasks} />
</Button>
</FormattedButtonTrigger>
}
modal
closeOnDocumentClick
Expand All @@ -576,9 +580,9 @@ export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
</p>
<Popup
trigger={
<Button className={styleClasses.actionClass}>
<FormattedButtonTrigger className={styleClasses.actionClass}>
<FormattedMessage {...messages.resetAllButton} />
</Button>
</FormattedButtonTrigger>
}
modal
closeOnDocumentClick
Expand All @@ -587,9 +591,9 @@ export const ActionsForm = ({ projectId, projectName, orgId }: Object) => {
</Popup>
<Popup
trigger={
<Button className={styleClasses.actionClass}>
<FormattedButtonTrigger className={styleClasses.actionClass}>
<FormattedMessage {...messages.resetBadImageryButton} />
</Button>
</FormattedButtonTrigger>
}
modal
closeOnDocumentClick
Expand Down

0 comments on commit dd5d203

Please sign in to comment.