Skip to content

Commit

Permalink
Improve RawVis fallback message when dataset is too big to display
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Aug 25, 2023
1 parent b1f0b07 commit d47bccf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/__tests__/CorePack.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('log raw dataset to console if too large', async () => {
const logSpy = mockConsoleMethod('log');
await renderApp('/entities/raw_large');

await expect(screen.findByText(/dataset is too big/)).resolves.toBeVisible();
await expect(screen.findByText(/Too big to display/)).resolves.toBeVisible();
expect(logSpy).toHaveBeenCalledWith(mockValues.raw_large);
});

Expand Down
17 changes: 17 additions & 0 deletions packages/lib/src/vis/raw/RawVis.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@

.fallback {
composes: fallback from global;
max-width: 26em;
line-height: 1.5;
}

.reason {
margin-top: 0;
margin-bottom: 0.75rem;
font-weight: 600;
}

.message {
margin-top: 0;
font-size: 0.875em;
}

.message > kbd {
font-weight: 600;
}
11 changes: 7 additions & 4 deletions packages/lib/src/vis/raw/RawVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ function RawVis(props: Props) {
console.log(value); // eslint-disable-line no-console

return (
<p className={styles.fallback}>
The dataset is too big to be displayed and was logged to the console
instead.
</p>
<div className={styles.fallback}>
<p className={styles.reason}>Too big to display</p>
<p className={styles.message}>
Dataset logged to the browser's developer console instead. Press{' '}
<kbd>F12</kbd> to open the developer tools and access the console.
</p>
</div>
);
}

Expand Down

0 comments on commit d47bccf

Please sign in to comment.