11<template >
22 <div class =" ext-neowiki-edit-summary" >
3- <CdxField
4- :optional =" true "
5- >
6- <template #label >
7- {{ $i18n( 'neowiki-edit-summary-label' ).text() }}
8- </template >
9- <CdxTextArea
10- v-model =" editSummary "
11- :placeholder =" $i18n ( ' neowiki-edit-summary-placeholder' ).text ()"
12- />
13- <template #help-text >
14- {{ props.helpText }}
3+ <CdxAccordion @toggle =" onAccordionToggle " >
4+ <template #title >
5+ <span class =" ext-neowiki-edit-summary__label" >
6+ {{ $i18n( 'neowiki-edit-summary-label' ).text() }}
7+ <span class =" ext-neowiki-edit-summary__optional-flag" >
8+ {{ $i18n( 'cdx-label-optional-flag' ).text() }}
9+ </span >
10+ </span >
1511 </template >
16- </CdxField >
12+
13+ <CdxField
14+ :optional =" true "
15+ :hide-label =" true "
16+ >
17+ <template #label >
18+ {{ $i18n( 'neowiki-edit-summary-label' ).text() }}
19+ </template >
20+
21+ <CdxTextArea
22+ ref="textAreaRef"
23+ v-model =" editSummary "
24+ :placeholder =" $i18n ( ' neowiki-edit-summary-placeholder' ).text ()"
25+ />
26+ </CdxField >
27+ </CdxAccordion >
28+
29+ <div
30+ v-if =" props.helpText"
31+ class =" ext-neowiki-edit-summary__help-text"
32+ >
33+ {{ props.helpText }}
34+ </div >
35+
1736 <div class =" ext-neowiki-edit-summary__actions" >
1837 <CdxButton
1938 action="progressive"
2948
3049<script setup lang="ts">
3150import { ref } from ' vue' ;
32- import { CdxButton , CdxField , CdxIcon , CdxTextArea } from ' @wikimedia/codex' ;
51+ import { CdxButton , CdxField , CdxIcon , CdxTextArea , CdxAccordion } from ' @wikimedia/codex' ;
3352import { cdxIconCheck } from ' @wikimedia/codex-icons' ;
3453
3554const props = defineProps <{
@@ -38,11 +57,22 @@ const props = defineProps<{
3857}>();
3958
4059const editSummary = ref ( ' ' );
60+ const textAreaRef = ref <InstanceType <typeof CdxTextArea > | null >( null );
4161
4262const emit = defineEmits <{
4363 save: [ summary : string ];
4464}>();
4565
66+ const onAccordionToggle = ( event : Event ): void => {
67+ const details = event .target as HTMLDetailsElement ;
68+ if ( details .open && textAreaRef .value ) {
69+ const textarea = textAreaRef .value .$el .querySelector ( ' textarea' );
70+ if ( textarea ) {
71+ textarea .focus ();
72+ }
73+ }
74+ };
75+
4676const onSaveClick = (): void => {
4777 emit ( ' save' , editSummary .value );
4878};
@@ -53,12 +83,44 @@ const onSaveClick = (): void => {
5383@use ' @wikimedia/codex-design-tokens/theme-wikimedia-ui.scss' as * ;
5484
5585.ext-neowiki-edit-summary {
56- display : flex ;
57- flex-direction : column ;
58- gap : $spacing-50 ;
86+ .cdx-accordion {
87+ border-bottom : 0 ;
88+
89+ > summary {
90+ margin-top : - $spacing-50 ;
91+ margin-inline : - $spacing-50 ;
92+ }
93+
94+ /* Reset the font size from accordion to match CdxField */
95+ & .cdx-accordion__header ,
96+ & __header__title ,
97+ & __content {
98+ font-size : inherit ;
99+ }
100+
101+ & __content {
102+ padding : 0 ;
103+ }
104+ }
105+
106+ & __optional-flag {
107+ color : $color-subtle ;
108+ font-weight : $font-weight-normal ;
109+ }
110+
111+ & __help-text {
112+ margin-top : $spacing-50 ;
113+ color : $color-subtle ;
114+ line-height : $line-height-xx-small ;
115+
116+ .cdx-accordion :not ( [ open ] ) + & {
117+ margin-top : 0 ;
118+ }
119+ }
59120
60121 & __actions {
61122 display : flex ;
123+ margin-top : $spacing-50 ;
62124 gap : $spacing-75 ;
63125
64126 .cdx-button {
0 commit comments