From 359962af6c5418a5e8820a551a23ee4f8b34621b Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 23 Nov 2021 11:16:31 +0000 Subject: [PATCH] Prevent text overlapping on poll options (#7187) --- res/css/views/messages/_MPollBody.scss | 20 +- src/components/views/messages/MPollBody.tsx | 12 +- .../__snapshots__/MPollBody-test.tsx.snap | 216 +++++++++++------- 3 files changed, 153 insertions(+), 95 deletions(-) diff --git a/res/css/views/messages/_MPollBody.scss b/res/css/views/messages/_MPollBody.scss index 0c307fbc4d..257e04cea7 100644 --- a/res/css/views/messages/_MPollBody.scss +++ b/res/css/views/messages/_MPollBody.scss @@ -57,15 +57,23 @@ limitations under the License. padding-top: 2px; } - .mx_MPollBody_optionVoteCount { - position: absolute; - color: $secondary-content; - right: 4px; - font-size: $font-12px; + .mx_StyledRadioButton_spacer { + display: none; + } + + .mx_MPollBody_optionDescription { + display: flex; + justify-content: space-between; + + .mx_MPollBody_optionVoteCount { + color: $secondary-content; + font-size: $font-12px; + white-space: nowrap; + } } .mx_MPollBody_popularityBackground { - width: calc(100% - 4px); + width: calc(100% - 6px); height: 8px; margin-right: 12px; border-radius: 8px; diff --git a/src/components/views/messages/MPollBody.tsx b/src/components/views/messages/MPollBody.tsx index ee2cd663d7..e9eede77fc 100644 --- a/src/components/views/messages/MPollBody.tsx +++ b/src/components/views/messages/MPollBody.tsx @@ -197,11 +197,13 @@ export default class MPollBody extends React.Component { checked={this.state.selected === answer.id} onChange={this.onOptionSelected} > -
- { _t("%(count)s votes", { count: answerVotes }) } -
-
- { answer[TEXT_NODE_TYPE] } +
+
+ { answer[TEXT_NODE_TYPE] } +
+
+ { _t("%(count)s votes", { count: answerVotes }) } +
diff --git a/test/components/views/messages/__snapshots__/MPollBody-test.tsx.snap b/test/components/views/messages/__snapshots__/MPollBody-test.tsx.snap index 37689b2011..543f178274 100644 --- a/test/components/views/messages/__snapshots__/MPollBody-test.tsx.snap +++ b/test/components/views/messages/__snapshots__/MPollBody-test.tsx.snap @@ -120,14 +120,18 @@ exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] = className="mx_StyledRadioButton_content" >
- 1 vote -
-
- Pizza +
+ Pizza +
+
+ 1 vote +
- 0 votes -
-
- Poutine +
+ Poutine +
+
+ 0 votes +
- 3 votes -
-
- Italian +
+ Italian +
+
+ 3 votes +
- 1 vote -
-
- Wings +
+ Wings +
+
+ 1 vote +
- 0 votes -
-
- Pizza +
+ Pizza +
+
+ 0 votes +
- 0 votes -
-
- Poutine +
+ Poutine +
+
+ 0 votes +
- 0 votes -
-
- Italian +
+ Italian +
+
+ 0 votes +
- 0 votes -
-
- Wings +
+ Wings +
+
+ 0 votes +
- 0 votes -
-
- Pizza +
+ Pizza +
+
+ 0 votes +
- 0 votes -
-
- Poutine +
+ Poutine +
+
+ 0 votes +
- 2 votes -
-
- Italian +
+ Italian +
+
+ 2 votes +
- 1 vote -
-
- Wings +
+ Wings +
+
+ 1 vote +