fix: fix newlines in poll option titles (#1717)
This commit is contained in:
parent
464864cd3d
commit
ec627f9732
|
@ -4,7 +4,7 @@
|
||||||
{#each options as option}
|
{#each options as option}
|
||||||
<li class="poll-choice option">
|
<li class="poll-choice option">
|
||||||
<div class="option-text">
|
<div class="option-text">
|
||||||
<strong>{option.share}%</strong> <span>{@html option.title}</span>
|
<strong>{option.share}%</strong> <span>{@html cleanTitle(option.title)}</span>
|
||||||
</div>
|
</div>
|
||||||
<svg aria-hidden="true">
|
<svg aria-hidden="true">
|
||||||
<line x1="0" y1="0" x2="{option.share}%" y2="0" />
|
<line x1="0" y1="0" x2="{option.share}%" y2="0" />
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
value="{i}"
|
value="{i}"
|
||||||
on:change="onChange()"
|
on:change="onChange()"
|
||||||
>
|
>
|
||||||
<span>{@html option.title}</span>
|
<span>{@html cleanTitle(option.title)}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -362,6 +362,14 @@
|
||||||
this.set({ choices: choices })
|
this.set({ choices: choices })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
helpers: {
|
||||||
|
cleanTitle (title) {
|
||||||
|
// Remove newlines and tabs.
|
||||||
|
// Mastodon UI doesn't care because in CSS it's formatted to be single-line, but we care
|
||||||
|
// if people somehow insert newlines, because it can really mess up the formatting.
|
||||||
|
return (title && title.replace(/[\n\t]+/g, ' ')) || ''
|
||||||
|
}
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
SvgIcon
|
SvgIcon
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue