Skip to content
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-formulieren/open-forms#4636] Preventing large values from breaking the table #183

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/components/builder/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {AnyComponentSchema} from '@/types/schemas';
import {Component, TextField} from '../formio';
import ComponentLabel from '../formio/component-label';
import './i18n.scss';
import './table.scss';
sergei-maertens marked this conversation as resolved.
Show resolved Hide resolved

type ExtractTranslatableProperties<T> = T extends OFExtensions<infer TK> ? TK : never;
type StringValueProperties<S> = S extends AnyComponentSchema
Expand Down Expand Up @@ -53,7 +54,7 @@ export function ComponentTranslations<S extends AnyComponentSchema>({

return (
<Component type="datagrid">
<table className="table table-bordered">
<table className="table table-bordered offb-table">
<thead>
<tr className="offb-i18n-header">
<td colSpan={2} className="offb-i18n-header__label">
Expand Down Expand Up @@ -122,7 +123,10 @@ export function ComponentTranslations<S extends AnyComponentSchema>({
</span>
</td>
<td>
<div aria-describedby={`component-translation-property-${property}`}>
<div
aria-describedby={`component-translation-property-${property}`}
className="offb-table__content--allow-break"
sergei-maertens marked this conversation as resolved.
Show resolved Hide resolved
>
{(values?.[property] || '-') as string}
</div>
</td>
Expand Down
11 changes: 11 additions & 0 deletions src/components/builder/table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.offb-table {
// Ensures that the column widths are respected
table-layout: fixed;

&__content {
&--allow-break {
overflow-wrap: break-word;
hyphens: auto;
}
}
}
23 changes: 19 additions & 4 deletions src/components/builder/values/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {TextArea, TextField} from '@/components/formio';
import {PathsForValueType} from '@/types';

import {ComponentTranslationsContext} from '../i18n';
import '../table.scss';

export interface ValuesTranslationsProps<S> {
/**
Expand Down Expand Up @@ -45,10 +46,17 @@ export function ValuesTranslations<S>({name, withOptionDescription}: ValuesTrans
<>
<tr key={`option-${index}`}>
<td>
<span id={`option-${index}-label`}>{label}</span>
<span id={`option-${index}-label`} className="offb-table__content--allow-break">
{label}
</span>
</td>
<td>
<div aria-describedby={`option-${index}-label`}>{value || '-'}</div>
<div
aria-describedby={`option-${index}-label`}
className="offb-table__content--allow-break"
>
{value || '-'}
</div>
</td>
<td>
<TextField
Expand Down Expand Up @@ -85,14 +93,21 @@ export function ValuesTranslations<S>({name, withOptionDescription}: ValuesTrans
description="Label for option description location"
defaultMessage="Option description (<option></option>)"
values={{
option: () => <code>{value || '-'}</code>,
option: () => (
<code className="offb-table__content--allow-break">{value || '-'}</code>
),
}}
/>
</span>
</td>

<td>
<div aria-describedby={`option-${index}-label`}>{description || '-'}</div>
<div
aria-describedby={`option-${index}-label`}
className="offb-table__content--allow-break"
>
{description || '-'}
</div>
</td>

<td>
Expand Down
Loading