Skip to content

Commit

Permalink
fix: update proposals page to prevent layout crash, handle correct ke…
Browse files Browse the repository at this point in the history
…y for list item in proposals to prevent page crash, update layout of proposal's description in proposals details page (#98)
  • Loading branch information
akhlopiachyi committed May 28, 2024
1 parent c43edbd commit a890320
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/web-coreum/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-coreum",
"version": "2.19.3-105",
"version": "2.19.3-106",
"license": "Apache-2.0",
"private": true,
"scripts": {
Expand Down
8 changes: 6 additions & 2 deletions packages/ui/src/components/markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ const options = {
},
};

export default function Markdown(props: { markdown: string }) {
export default function Markdown(props: { markdown: string; className?: string }) {
const clean = xss(props.markdown.replace(/\\n\s?/g, '<br/>'));
// clean = clean.replace(/\\n\s?/g, '\n'); // this will also work

return <ReactMarkdown options={options}>{clean}</ReactMarkdown>;
return (
<ReactMarkdown options={options} className={props.className}>
{clean}
</ReactMarkdown>
);
}
1 change: 1 addition & 0 deletions packages/ui/src/components/single_proposal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const useStyles = makeStyles()((theme) => ({
},
content: {
marginBottom: theme.spacing(2),
wordBreak: 'break-word',
},
id: {
color: theme.palette.custom.fonts.fontThree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ exports[`screen: BlockDetails/Overview matches snapshot 1`] = `
line-height: 1.5;
}
.emotion-9 {
word-break: break-word;
}
<div
className="emotion-0"
id="Box"
Expand Down Expand Up @@ -135,6 +139,7 @@ exports[`screen: BlockDetails/Overview matches snapshot 1`] = `
description
</p>
<div
className="value emotion-9"
id="Markdown"
markdown="description"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const Overview: FC<{ className?: string; overview: OverviewType }> = ({ classNam
<Typography variant="body1" className="label">
{t('description')}
</Typography>
<Markdown markdown={overview.description} />
<Markdown markdown={overview.description} className={cx('value', classes.description)} />
{extra}
</div>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const useStyles = makeStyles()((theme) => ({
gridTemplateColumns: 'repeat(2, 1fr)',
},
},
description: {
wordBreak: 'break-word',
},
}));

export default useStyles;
5 changes: 2 additions & 3 deletions packages/ui/src/screens/proposals/components/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ const ListItem: FC<ListItemProps> = ({
}

const formattedItem = {
description:
item.description.length > 200 ? `${item.description.slice(0, 200)}...` : item.description,
description: item.description,
status: item.status,
title: (
<Link shallow href={PROPOSAL_DETAILS(item.id)} className="value">
Expand Down Expand Up @@ -113,7 +112,7 @@ const ProposalsList: FC<ProposalsListProps> = ({
>
{({ index, style }) => (
<ListItem
key={items[index].id}
key={`proposal-list-item-${items[index]?.id}`}
index={index}
style={style}
setRowHeight={setRowHeight}
Expand Down

0 comments on commit a890320

Please sign in to comment.