Skip to content

Commit da0f524

Browse files
committed
feat(QExpansionItem): small improvements to toggle icon & perf
1 parent fe2b525 commit da0f524

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

ui/dev/src/pages/components/list-expansion-item.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,29 +299,29 @@
299299
Switch toggle side
300300
</p>
301301
<q-list bordered padding inset-separator>
302-
<q-expansion-item switch-toggle-side icon="mail" label="Inbox" caption="5 unread emails">
302+
<q-expansion-item expand-icon-toggle switch-toggle-side icon="mail" label="Inbox" caption="5 unread emails">
303303
<q-card>
304304
<q-card-section>
305305
{{ lorem }}
306306
</q-card-section>
307307
</q-card>
308308
</q-expansion-item>
309-
<q-expansion-item switch-toggle-side icon="send" label="Outbox" caption="Empty">
309+
<q-expansion-item expand-icon-toggle switch-toggle-side icon="send" label="Outbox" caption="Empty">
310310
<q-card>
311311
<q-card-section>
312312
{{ lorem }}
313313
</q-card-section>
314314
</q-card>
315315
</q-expansion-item>
316316
<q-separator />
317-
<q-expansion-item switch-toggle-side dense-toggle icon="mail" label="Inbox" caption="5 unread emails">
317+
<q-expansion-item expand-icon-toggle switch-toggle-side dense-toggle icon="mail" label="Inbox" caption="5 unread emails">
318318
<q-card>
319319
<q-card-section>
320320
{{ lorem }}
321321
</q-card-section>
322322
</q-card>
323323
</q-expansion-item>
324-
<q-expansion-item switch-toggle-side dense-toggle icon="mail" label="Inbox" caption="5 unread emails">
324+
<q-expansion-item expand-icon-toggle switch-toggle-side dense-toggle icon="mail" label="Inbox" caption="5 unread emails">
325325
<q-card>
326326
<q-card-section>
327327
{{ lorem }}

ui/src/components/expansion-item/QExpansionItem.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,33 +126,42 @@ export default Vue.extend({
126126
},
127127

128128
__getToggleIcon (h) {
129-
return h(QItemSection, {
129+
const data = {
130130
staticClass: `q-focusable relative-position cursor-pointer${this.denseToggle === true && this.switchToggleSide === true ? ' items-end' : ''}`,
131131
class: this.expandIconClass,
132132
props: {
133133
side: this.switchToggleSide !== true,
134134
avatar: this.switchToggleSide
135-
},
136-
attrs: this.activeToggleIcon === true
137-
? { tabindex: 0 }
138-
: void 0,
139-
on: this.activeToggleIcon === true ? cache(this, 'inpExt', {
140-
click: this.__toggleIcon,
141-
keyup: this.__toggleIconKeyboard
142-
}) : null
143-
}, [
144-
h('div', {
145-
ref: 'blurTarget',
146-
staticClass: 'q-expansion-item__toggle-focus q-icon q-focus-helper q-focus-helper--rounded',
147-
attrs: { tabindex: -1 }
148-
}),
135+
}
136+
}
149137

138+
const child = [
150139
h(QIcon, {
151140
staticClass: 'q-expansion-item__toggle-icon',
152-
class: this.showing === true ? 'rotate-180' : void 0,
141+
class: this.showing === true ? 'q-expansion-item__toggle-icon--rotated' : void 0,
153142
props: { name: this.expansionIcon }
154143
})
155-
])
144+
]
145+
146+
if (this.activeToggleIcon === true) {
147+
Object.assign(data, {
148+
attrs: { tabindex: 0 },
149+
on: cache(this, 'inpExt', {
150+
click: this.__toggleIcon,
151+
keyup: this.__toggleIconKeyboard
152+
})
153+
})
154+
155+
child.unshift(
156+
h('div', {
157+
ref: 'blurTarget',
158+
staticClass: 'q-expansion-item__toggle-focus q-icon q-focus-helper q-focus-helper--rounded',
159+
attrs: { tabindex: -1 }
160+
})
161+
)
162+
}
163+
164+
return h(QItemSection, data, child)
156165
},
157166

158167
__getHeader (h) {

ui/src/components/expansion-item/QExpansionItem.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
position: relative
99
transition: transform .3s
1010

11+
&--rotated
12+
transform: rotate(180deg)
13+
1114
&__toggle-focus
1215
top: auto !important
1316
left: auto !important

ui/src/components/expansion-item/QExpansionItem.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
position: relative
99
transition: transform .3s
1010

11+
&--rotated
12+
transform: rotate(180deg)
13+
1114
&__toggle-focus
1215
top: auto !important
1316
left: auto !important

0 commit comments

Comments
 (0)