diff --git a/services/web/.babelrc b/services/web/.babelrc index d2b230bb27..d354026e94 100644 --- a/services/web/.babelrc +++ b/services/web/.babelrc @@ -7,14 +7,18 @@ }] ], "plugins": ["angularjs-annotate"], - // Disable core-js polyfilling in test environment, to prevent interference - // with mocking + // Target our current Node version in test environment, to transform and + // polyfill only what's necessary "env": { "test": { "presets": [ "@babel/react", - "@babel/env" + ["@babel/env", { + "targets": {"node": "10.21"}, + "useBuiltIns": "usage", + "corejs": { "version": 3 } + }] ] } } -} \ No newline at end of file +} diff --git a/services/web/frontend/extracted-translation-keys.json b/services/web/frontend/extracted-translation-keys.json index 4faef59296..35f8a2d908 100644 --- a/services/web/frontend/extracted-translation-keys.json +++ b/services/web/frontend/extracted-translation-keys.json @@ -2,5 +2,7 @@ "file_outline", "the_file_outline_is_a_new_feature_click_the_icon_to_learn_more", "we_cant_find_any_sections_or_subsections_in_this_file", - "find_out_more_about_the_file_outline" + "find_out_more_about_the_file_outline", + "expand", + "collapse" ] diff --git a/services/web/frontend/js/features/outline/components/outline-item.js b/services/web/frontend/js/features/outline/components/outline-item.js index fb775b33c9..4749121a8c 100644 --- a/services/web/frontend/js/features/outline/components/outline-item.js +++ b/services/web/frontend/js/features/outline/components/outline-item.js @@ -2,6 +2,7 @@ import React, { useState, useEffect, createRef, useRef } from 'react' import PropTypes from 'prop-types' import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed' import classNames from 'classnames' +import { useTranslation } from 'react-i18next' import OutlineList from './outline-list' function getChildrenLines(children) { @@ -13,6 +14,8 @@ function getChildrenLines(children) { } function OutlineItem({ outlineItem, jumpToLine, highlightedLine }) { + const { t } = useTranslation() + const [expanded, setExpanded] = useState(true) const titleElementRef = createRef() const isHighlightedRef = useRef(false) @@ -30,9 +33,11 @@ function OutlineItem({ outlineItem, jumpToLine, highlightedLine }) { !expanded && getChildrenLines(outlineItem.children).includes(highlightedLine) + const isHighlighted = + highlightedLine === outlineItem.line || hasHighlightedChild + const itemLinkClasses = classNames('outline-item-link', { - 'outline-item-link-highlight': - highlightedLine === outlineItem.line || hasHighlightedChild + 'outline-item-link-highlight': isHighlighted }) function handleExpandCollapseClick() { @@ -64,13 +69,23 @@ function OutlineItem({ outlineItem, jumpToLine, highlightedLine }) { [highlightedLine, titleElementRef, isHighlightedRef] ) + // don't set the aria-expanded attribute when there are no children + const ariaExpandedValue = outlineItem.children ? expanded : undefined + return ( -