Skip to content

Update sdkOption to avoid rendering divs inside of tables #14562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 19 additions & 7 deletions src/components/sdkOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {getCurrentPlatformOrGuide} from 'sentry-docs/docTree';
import {serverContext} from 'sentry-docs/serverContext';
import {PlatformCategory} from 'sentry-docs/types';

import {PlatformCategorySection} from './platformCategorySection';
import {PlatformSection} from './platformSection';
Comment on lines -5 to -6
Copy link
Member

Choose a reason for hiding this comment

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

Is this being used anywhere else? If so, do we have the same issue?

Copy link
Contributor Author

@coolguyzone coolguyzone Aug 11, 2025

Choose a reason for hiding this comment

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

Yeah, it is a useful component and works as expected with other elements, it just doesn't serve to have it render inside a table because it injects a <div>. Another approach could be to modify the component to have a table prop and omit the <div>; the result would be similar.

import {SdkDefinition, SdkDefinitionTable} from './sdkDefinition';

type Props = {
Expand All @@ -28,6 +26,21 @@ export function SdkOption({
categorySupported = [],
}: Props) {
const {showBrowserOnly, showServerLikeOnly} = getPlatformHints(categorySupported);
const {rootNode, path} = serverContext();
const currentPlatformOrGuide = getCurrentPlatformOrGuide(rootNode, path);
const shouldShowEnvVar = () => {
if (!currentPlatformOrGuide) return false;

const isServerPlatform =
currentPlatformOrGuide.categories?.includes('server') ||
currentPlatformOrGuide.categories?.includes('serverless');

const isExcludedPlatform =
currentPlatformOrGuide.key === 'javascript.nextjs' ||
currentPlatformOrGuide.key === 'javascript.sveltekit';

return isServerPlatform && !isExcludedPlatform;
};

return (
<SdkDefinition name={name} categorySupported={categorySupported}>
Expand All @@ -39,11 +52,10 @@ export function SdkOption({
{defaultValue && (
<OptionDefRow label="Default" value={defaultValue} note={defaultNote} />
)}
<PlatformCategorySection supported={['server', 'serverless']}>
<PlatformSection notSupported={['javascript.nextjs', 'javascript.sveltekit']}>
{envVar && <OptionDefRow label="ENV Variable" value={envVar} />}
</PlatformSection>
</PlatformCategorySection>

{shouldShowEnvVar() && envVar && (
<OptionDefRow label="ENV Variable" value={envVar} />
)}

{showBrowserOnly && <OptionDefRow label="Only available on" value="Client" />}
{showServerLikeOnly && <OptionDefRow label="Only available on" value="Server" />}
Expand Down
Loading