Skip to content

Commit 33503a1

Browse files
committed
refactor(Notify): small tweaks to Notify's new "attrs" props quasarframework#7477 quasarframework#7482
1 parent 931d70a commit 33503a1

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

docs/src/pages/quasar-plugins/notify.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,21 @@ You can use HTML on message if you specify the `html: true` prop. **Please note
105105
<doc-example title="Unsafe HTML message" file="Notify/UnsafeHtml" />
106106

107107
### Setting attributes
108-
You can set custom attributes on the notification by setting the `attrs` key of the configuration object.
109-
You can set custom attributes on the notification actions by setting the `attrs` key of the configuration object of the action.
108+
You can set custom HTML attributes on the notification itself or on individual notification actions by setting the `attrs` Object property.
110109

111110
```js
112111
this.$q.notify({
113112
...
114113

115114
attrs: {
115+
// for the notification itself:
116116
role: 'alertdialog'
117117
},
118118

119119
actions: [
120120
{
121121
icon: 'close',
122+
// for individual action (button):
122123
attrs: {
123124
'aria-label': 'Dismiss'
124125
}

ui/src/plugins/Notify.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { isSSR } from './Platform.js'
1111
let uid = 0
1212
const defaults = {}
1313

14-
const attrs = { role: 'alert' }
15-
1614
const positionList = [
1715
'top-left', 'top-right',
1816
'bottom-left', 'bottom-right',
@@ -60,7 +58,7 @@ const Notifications = {
6058
this.notifs[pos] = []
6159

6260
const
63-
vert = ['left', 'center', 'right'].includes(pos) ? 'center' : (pos.indexOf('top') > -1 ? 'top' : 'bottom'),
61+
vert = ['left', 'center', 'right'].includes(pos) === true ? 'center' : (pos.indexOf('top') > -1 ? 'top' : 'bottom'),
6462
align = pos.indexOf('left') > -1 ? 'start' : (pos.indexOf('right') > -1 ? 'end' : 'center'),
6563
classes = ['left', 'right'].includes(pos) ? `items-${pos === 'left' ? 'start' : 'end'} justify-center` : (pos === 'center' ? 'flex-center' : `items-${align}`)
6664

@@ -180,7 +178,7 @@ const Notifications = {
180178
(notif.multiLine === true ? '' : ' col'),
181179

182180
attrs: {
183-
...attrs,
181+
role: 'alert',
184182
...notif.attrs
185183
}
186184
})

ui/src/plugins/Notify.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@
138138
"attrs": {
139139
"type": "Object",
140140
"desc": "Key-value for attributes to be set on the notification",
141-
"examples": [ "{ 'aria-label': 'Button label' }" ],
142-
"__exemption": [ "definition" ]
141+
"examples": [ "{ role: 'alertdialog' }" ],
142+
"__exemption": [ "definition" ],
143+
"addedIn": "v1.13.0"
143144
},
144145

145146
"timeout": {
@@ -304,8 +305,9 @@
304305
"attrs": {
305306
"type": "Object",
306307
"desc": "Key-value for attributes to be set on the notification",
307-
"examples": [ "{ 'aria-label': 'Button label' }" ],
308-
"__exemption": [ "definition" ]
308+
"examples": [ "{ role: 'alertdialog' }" ],
309+
"__exemption": [ "definition" ],
310+
"addedIn": "v1.13.0"
309311
},
310312

311313
"timeout": {
@@ -494,8 +496,9 @@
494496
"attrs": {
495497
"type": "Object",
496498
"desc": "Key-value for attributes to be set on the notification",
497-
"examples": [ "{ 'aria-label': 'Button label' }" ],
498-
"__exemption": [ "definition" ]
499+
"examples": [ "{ role: 'alertdialog' }" ],
500+
"__exemption": [ "definition" ],
501+
"addedIn": "v1.13.0"
499502
},
500503

501504
"timeout": {
@@ -680,8 +683,9 @@
680683
"attrs": {
681684
"type": "Object",
682685
"desc": "Key-value for attributes to be set on the notification",
683-
"examples": [ "{ 'aria-label': 'Button label' }" ],
684-
"__exemption": [ "definition" ]
686+
"examples": [ "{ role: 'alertdialog' }" ],
687+
"__exemption": [ "definition" ],
688+
"addedIn": "v1.13.0"
685689
},
686690

687691
"timeout": {

0 commit comments

Comments
 (0)