Skip to content

Commit 6016bc4

Browse files
authored
Merge pull request #2650 from ably/web-4440-docs-lang-filtering
[WEB-4440] fix: restrict dl child filtering to active language from context
2 parents cd708c1 + cf5b1c9 commit 6016bc4

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/components/blocks/list/Dl/DlWrapper.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { Children, FunctionComponent } from 'react';
2-
import { useLayoutContext, DEFAULT_LANGUAGE } from 'src/contexts/layout-context';
2+
import { useLayoutContext } from 'src/contexts/layout-context';
33

4-
export const DlWrapper: FunctionComponent<unknown> = ({ children }) => {
4+
type DlWrapperProps = {
5+
children: React.ReactElement<{
6+
attribs?: {
7+
lang?: string;
8+
};
9+
}>[];
10+
};
11+
12+
export const DlWrapper: FunctionComponent<DlWrapperProps> = ({ children }) => {
513
const { activePage } = useLayoutContext();
614

715
return Children.map(children, (child) => {
816
const attribs = child?.props?.attribs;
917

1018
if (attribs?.lang) {
11-
if (
12-
(activePage.language === DEFAULT_LANGUAGE && attribs?.lang === DEFAULT_LANGUAGE) ||
13-
attribs?.lang === activePage.language ||
14-
attribs?.lang === DEFAULT_LANGUAGE
15-
) {
19+
if (attribs.lang === activePage.language) {
1620
return child;
1721
}
1822
return null;

src/components/blocks/software/Pre.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Icon from '@ably/ui/core/Icon';
44
import Html from '../Html';
55
import LocalLanguageAlternatives from '../wrappers/LocalLanguageAlternatives';
66
import {
7-
DEFAULT_LANGUAGE,
87
DEFAULT_PREFERRED_INTERFACE,
98
DEFAULT_PREFERRED_LANGUAGE,
109
REALTIME_SDK_INTERFACE,
@@ -67,8 +66,7 @@ const Pre = ({
6766

6867
const codeClassName = 'bg-cool-black text-white p-0 rounded-lg relative max-w-[calc(100vw-48px)] sm:max-w-full';
6968

70-
const hasCode =
71-
languages?.some((lang) => getTrimmedLanguage(lang) === pageLanguage) || pageLanguage === DEFAULT_LANGUAGE;
69+
const hasCode = languages?.some((lang) => getTrimmedLanguage(lang) === pageLanguage);
7270
const shouldDisplayTip = !hasCode && languages?.length !== undefined;
7371
const withModifiedClassname = {
7472
...attribs,

0 commit comments

Comments
 (0)