Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/lib/components/DefinitionTooltip/DefinitionTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ import positionTooltip from "../../helpers/positionTooltip.js";
url [String] - A url to link to. Will take precedence over onClick.
*/

const DefinitionTooltip = props => {
const DefinitionTooltip = (props) => {
const {
classes,
definition,
explanation,
id,
link,
onClick,
position,
position = "top",
term,
url
url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this trailing comma?

Copy link
Collaborator Author

@shruti-14 shruti-14 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is added by linter.

} = props;

const tooltipElementId = `${id}-desc`;
const tooltipRef = useRef(null);
const triggerClass = classnames("dfn-tooltip-trigger", classes);

const handleMouseEnter = event => {
const handleMouseEnter = (event) => {
const currentTooltip = tooltipRef.current;
positionTooltip(currentTooltip, position);
};
Expand All @@ -68,7 +68,7 @@ const DefinitionTooltip = props => {
aria-labelledby={tooltipElementId}
className={triggerClass}
dangerouslySetInnerHTML={{
__html: term
__html: term,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these trailing commas being added by a linter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

}}
href={url}
onMouseEnter={handleMouseEnter}
Expand All @@ -82,7 +82,7 @@ const DefinitionTooltip = props => {
aria-labelledby={tooltipElementId}
className={triggerClass}
dangerouslySetInnerHTML={{
__html: term
__html: term,
}}
onClick={onClick}
onMouseEnter={handleMouseEnter}
Expand All @@ -100,7 +100,7 @@ const DefinitionTooltip = props => {
>
<span
dangerouslySetInnerHTML={{
__html: term
__html: term,
}}
/>
</Link>
Expand All @@ -118,7 +118,7 @@ const DefinitionTooltip = props => {
>
<p
dangerouslySetInnerHTML={{
__html: `<dfn>${term}:</dfn> ${definition}`
__html: `<dfn>${term}:</dfn> ${definition}`,
}}
id={`${id}-definition`}
/>
Expand All @@ -134,10 +134,6 @@ const DefinitionTooltip = props => {
);
};

DefinitionTooltip.defaultProps = {
position: "top"
};

DefinitionTooltip.propTypes = {
classes: PropTypes.string,
definition: PropTypes.string.isRequired,
Expand All @@ -147,7 +143,7 @@ DefinitionTooltip.propTypes = {
onClick: PropTypes.func,
position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
term: PropTypes.string.isRequired,
url: PropTypes.string
url: PropTypes.string,
};

export default DefinitionTooltip;
19 changes: 7 additions & 12 deletions src/lib/components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import classnames from "classnames";
const TextInput = React.forwardRef((props, ref) => {
const {
autoComplete,
autoFocus,
autoFocus = false,
classes,
disabled,
feedbackContext,
Expand All @@ -79,22 +79,22 @@ const TextInput = React.forwardRef((props, ref) => {
placeholder,
polite,
readOnly,
required,
required = false,
step,
type,
value
value,
} = props;

const controlClasses = classnames("text", "control", classes, {
disabled: disabled,
inline: inline,
invalid: isValid !== undefined && !isValid
invalid: isValid !== undefined && !isValid,
});
const feedbackClasses = classnames(
"control-feedback",
`${feedbackContext || "error"}`,
{
"visually-hidden": !feedbackText
"visually-hidden": !feedbackText,
}
);
const feedbackId = `${id}-feedback`;
Expand Down Expand Up @@ -191,14 +191,9 @@ TextInput.propTypes = {
"text",
"time",
"url",
"week"
"week",
]),
value: PropTypes.string
};

TextInput.defaultProps = {
autoFocus: false,
required: false
value: PropTypes.string,
};

export default TextInput;
9 changes: 2 additions & 7 deletions src/lib/components/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const Tooltip = (props) => {
id,
link,
onClick,
position,
position = "top",
text,
tooltipBody,
url,
buttonType
buttonType = "button",
} = props;

const tooltipElementId = `${id}-desc`;
Expand Down Expand Up @@ -119,11 +119,6 @@ const Tooltip = (props) => {
);
};

Tooltip.defaultProps = {
position: "top",
buttonType: "button"
};

Tooltip.propTypes = {
classes: PropTypes.string,
tooltipBody: PropTypes.string.isRequired,
Expand Down