Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
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
14 changes: 14 additions & 0 deletions src/components/information/QuestionEditField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const requiredRule = (v: unknown) => (v === undefined || v === null ? '必須項
:rules="[requiredRule]"
:disabled="!question.isOpen"
variant="underlined"
:class="$style.wrapText"
></v-text-field>
<v-number-input
v-if="question.type === 'free_number'"
Expand All @@ -30,6 +31,7 @@ const requiredRule = (v: unknown) => (v === undefined || v === null ? '必須項
:disabled="!question.isOpen"
variant="underlined"
control-variant="hidden"
:class="$style.wrapText"
></v-number-input>
<v-select
v-if="question.type === 'single'"
Expand All @@ -42,6 +44,7 @@ const requiredRule = (v: unknown) => (v === undefined || v === null ? '必須項
:items="question.options"
:item-value="(option) => option.id"
:item-title="(option) => option.content"
:class="$style.wrapText"
></v-select>
<v-select
v-if="question.type === 'multiple'"
Expand All @@ -55,5 +58,16 @@ const requiredRule = (v: unknown) => (v === undefined || v === null ? '必須項
:items="question.options"
:item-value="(option) => option.id"
:item-title="(option) => option.content"
:class="$style.wrapText"
></v-select>
</template>

<style module>
.wrapText :global(.v-select__selection-text) {
white-space: normal !important;
}

:global(.v-overlay-container) :global(.v-list-item-title) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:global(.v-overlay-container) :global(.v-list-item-title) {
.wrapText :global(.v-list-item-title) {

という限定をすると影響をこのコンポーネント(QuestionEditField.vue)の中に閉じ込めることができてうれしそう

CSS Modules によって、このスタイルの .wrapText の部分がプロダクト全体で一意な文字列に置き換えられて dist に含まれることになります

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v-list-item-title(プルダウンででてくるやつ)なんですがvuetifyの仕様でteleportされてbody直下のv-overlay-containerに飛ばされるんですよね。
試してみたんですがquestion editerfieldの外で描画されていて上手くいかなかったです。

このコンポーネントとは別の箇所にcssで影響を与えるため先頭を:globalにしています。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

せめてもの制限でoverlay-containerを先頭に付けていますが別のコンポーネントでも同じようなv-selectを使うと同様に折り返しが強制されてしまいそうです。
避けるの難しいかも

white-space: normal;
}
</style>
4 changes: 2 additions & 2 deletions src/mocks/handlers/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export const questionsHandlers = [
},
{
id: 4,
title: 'スキーセット',
title: 'スキーセットを借りるか借りないかを教えてください',
type: 'single',
options: [
{ id: 7, content: '借りる' },
{ id: 7, content: '借りるかもしれないしかりないかもしれない、この文章は長いので折り返される。スキー好き' },
{ id: 8, content: '借りない' },
],
isPublic: false,
Expand Down