@ckeditor/ckeditor5-ui 35.2.0 → 35.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +31 -23
- package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
- package/src/bindings/clickoutsidehandler.js +15 -21
- package/src/bindings/injectcsstransitiondisabler.js +16 -20
- package/src/bindings/preventdefault.js +6 -8
- package/src/bindings/submithandler.js +5 -7
- package/src/button/button.js +5 -0
- package/src/button/buttonview.js +220 -259
- package/src/button/switchbuttonview.js +56 -71
- package/src/colorgrid/colorgridview.js +135 -197
- package/src/colorgrid/colortileview.js +37 -47
- package/src/colorgrid/utils.js +57 -66
- package/src/componentfactory.js +79 -93
- package/src/dropdown/button/dropdownbutton.js +5 -0
- package/src/dropdown/button/dropdownbuttonview.js +44 -57
- package/src/dropdown/button/splitbuttonview.js +159 -207
- package/src/dropdown/dropdownpanelfocusable.js +5 -0
- package/src/dropdown/dropdownpanelview.js +101 -112
- package/src/dropdown/dropdownview.js +396 -438
- package/src/dropdown/utils.js +164 -213
- package/src/editableui/editableuiview.js +125 -141
- package/src/editableui/inline/inlineeditableuiview.js +44 -54
- package/src/editorui/bodycollection.js +61 -75
- package/src/editorui/boxed/boxededitoruiview.js +91 -104
- package/src/editorui/editoruiview.js +30 -39
- package/src/focuscycler.js +214 -245
- package/src/formheader/formheaderview.js +58 -70
- package/src/icon/iconview.js +145 -111
- package/src/iframe/iframeview.js +37 -49
- package/src/index.js +0 -17
- package/src/input/inputview.js +170 -198
- package/src/inputnumber/inputnumberview.js +48 -56
- package/src/inputtext/inputtextview.js +14 -18
- package/src/label/labelview.js +44 -53
- package/src/labeledfield/labeledfieldview.js +212 -235
- package/src/labeledfield/utils.js +39 -57
- package/src/labeledinput/labeledinputview.js +190 -221
- package/src/list/listitemview.js +40 -50
- package/src/list/listseparatorview.js +15 -19
- package/src/list/listview.js +94 -115
- package/src/model.js +19 -25
- package/src/notification/notification.js +151 -202
- package/src/panel/balloon/balloonpanelview.js +535 -628
- package/src/panel/balloon/contextualballoon.js +611 -732
- package/src/panel/sticky/stickypanelview.js +238 -270
- package/src/template.js +1049 -1479
- package/src/toolbar/balloon/balloontoolbar.js +337 -424
- package/src/toolbar/block/blockbuttonview.js +32 -42
- package/src/toolbar/block/blocktoolbar.js +375 -477
- package/src/toolbar/normalizetoolbarconfig.js +17 -21
- package/src/toolbar/toolbarlinebreakview.js +15 -19
- package/src/toolbar/toolbarseparatorview.js +15 -19
- package/src/toolbar/toolbarview.js +866 -1053
- package/src/tooltipmanager.js +324 -353
- package/src/view.js +389 -430
- package/src/viewcollection.js +147 -178
- package/src/button/button.jsdoc +0 -165
- package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
- package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
package/src/dropdown/utils.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module ui/dropdown/utils
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import DropdownPanelView from './dropdownpanelview';
|
|
11
9
|
import DropdownView from './dropdownview';
|
|
12
10
|
import DropdownButtonView from './button/dropdownbuttonview';
|
|
@@ -15,15 +13,12 @@ import ListView from '../list/listview';
|
|
|
15
13
|
import ListItemView from '../list/listitemview';
|
|
16
14
|
import ListSeparatorView from '../list/listseparatorview';
|
|
17
15
|
import ButtonView from '../button/buttonview';
|
|
16
|
+
import SplitButtonView from './button/splitbuttonview';
|
|
18
17
|
import SwitchButtonView from '../button/switchbuttonview';
|
|
19
|
-
|
|
20
18
|
import clickOutsideHandler from '../bindings/clickoutsidehandler';
|
|
21
|
-
|
|
22
19
|
import { global, priorities, logWarning } from '@ckeditor/ckeditor5-utils';
|
|
23
|
-
|
|
24
20
|
import '../../theme/components/dropdown/toolbardropdown.css';
|
|
25
21
|
import '../../theme/components/dropdown/listdropdown.css';
|
|
26
|
-
|
|
27
22
|
/**
|
|
28
23
|
* A helper for creating dropdowns. It creates an instance of a {@link module:ui/dropdown/dropdownview~DropdownView dropdown},
|
|
29
24
|
* with a {@link module:ui/dropdown/button/dropdownbutton~DropdownButton button},
|
|
@@ -86,25 +81,20 @@ import '../../theme/components/dropdown/listdropdown.css';
|
|
|
86
81
|
* {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface.
|
|
87
82
|
* @returns {module:ui/dropdown/dropdownview~DropdownView} The dropdown view instance.
|
|
88
83
|
*/
|
|
89
|
-
export function createDropdown(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
addDefaultBehavior( dropdownView );
|
|
104
|
-
|
|
105
|
-
return dropdownView;
|
|
84
|
+
export function createDropdown(locale, ButtonClass = DropdownButtonView) {
|
|
85
|
+
const buttonView = new ButtonClass(locale);
|
|
86
|
+
const panelView = new DropdownPanelView(locale);
|
|
87
|
+
const dropdownView = new DropdownView(locale, buttonView, panelView);
|
|
88
|
+
buttonView.bind('isEnabled').to(dropdownView);
|
|
89
|
+
if (buttonView instanceof SplitButtonView) {
|
|
90
|
+
buttonView.arrowView.bind('isOn').to(dropdownView, 'isOpen');
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
buttonView.bind('isOn').to(dropdownView, 'isOpen');
|
|
94
|
+
}
|
|
95
|
+
addDefaultBehavior(dropdownView);
|
|
96
|
+
return dropdownView;
|
|
106
97
|
}
|
|
107
|
-
|
|
108
98
|
/**
|
|
109
99
|
* Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.
|
|
110
100
|
*
|
|
@@ -140,30 +130,24 @@ export function createDropdown( locale, ButtonClass = DropdownButtonView ) {
|
|
|
140
130
|
* as a whole resulting in the focus moving to its first focusable item (default behavior of
|
|
141
131
|
* {@link module:ui/dropdown/dropdownview~DropdownView}).
|
|
142
132
|
*/
|
|
143
|
-
export function addToolbarToDropdown(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
focusChildOnDropdownOpen( dropdownView, () => toolbarView.items.find( item => item.isOn ) );
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
dropdownView.panelView.children.add( toolbarView );
|
|
164
|
-
toolbarView.items.delegate( 'execute' ).to( dropdownView );
|
|
133
|
+
export function addToolbarToDropdown(dropdownView, buttons, options = {}) {
|
|
134
|
+
const locale = dropdownView.locale;
|
|
135
|
+
const t = locale.t;
|
|
136
|
+
const toolbarView = dropdownView.toolbarView = new ToolbarView(locale);
|
|
137
|
+
toolbarView.set('ariaLabel', t('Dropdown toolbar'));
|
|
138
|
+
dropdownView.extendTemplate({
|
|
139
|
+
attributes: {
|
|
140
|
+
class: ['ck-toolbar-dropdown']
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
buttons.map(view => toolbarView.items.add(view));
|
|
144
|
+
if (options.enableActiveItemFocusOnDropdownOpen) {
|
|
145
|
+
// Accessibility: Focus the first active button in the toolbar when the dropdown gets open.
|
|
146
|
+
focusChildOnDropdownOpen(dropdownView, () => toolbarView.items.find((item) => item.isOn));
|
|
147
|
+
}
|
|
148
|
+
dropdownView.panelView.children.add(toolbarView);
|
|
149
|
+
toolbarView.items.delegate('execute').to(dropdownView);
|
|
165
150
|
}
|
|
166
|
-
|
|
167
151
|
/**
|
|
168
152
|
* Adds an instance of {@link module:ui/list/listview~ListView} to a dropdown.
|
|
169
153
|
*
|
|
@@ -209,47 +193,40 @@ export function addToolbarToDropdown( dropdownView, buttons, options = {} ) {
|
|
|
209
193
|
* @param {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition>} items
|
|
210
194
|
* A collection of the list item definitions to populate the list.
|
|
211
195
|
*/
|
|
212
|
-
export function addListToDropdown(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if ( item instanceof ListItemView ) {
|
|
246
|
-
return item.children.first.isOn;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return false;
|
|
250
|
-
} ) );
|
|
196
|
+
export function addListToDropdown(dropdownView, items) {
|
|
197
|
+
const locale = dropdownView.locale;
|
|
198
|
+
const listView = dropdownView.listView = new ListView(locale);
|
|
199
|
+
listView.items.bindTo(items).using(def => {
|
|
200
|
+
if (def.type === 'separator') {
|
|
201
|
+
return new ListSeparatorView(locale);
|
|
202
|
+
}
|
|
203
|
+
else if (def.type === 'button' || def.type === 'switchbutton') {
|
|
204
|
+
const listItemView = new ListItemView(locale);
|
|
205
|
+
let buttonView;
|
|
206
|
+
if (def.type === 'button') {
|
|
207
|
+
buttonView = new ButtonView(locale);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
buttonView = new SwitchButtonView(locale);
|
|
211
|
+
}
|
|
212
|
+
// Bind all model properties to the button view.
|
|
213
|
+
buttonView.bind(...Object.keys(def.model)).to(def.model);
|
|
214
|
+
buttonView.delegate('execute').to(listItemView);
|
|
215
|
+
listItemView.children.add(buttonView);
|
|
216
|
+
return listItemView;
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
});
|
|
220
|
+
dropdownView.panelView.children.add(listView);
|
|
221
|
+
listView.items.delegate('execute').to(dropdownView);
|
|
222
|
+
// Accessibility: Focus the first active button in the list when the dropdown gets open.
|
|
223
|
+
focusChildOnDropdownOpen(dropdownView, () => listView.items.find(item => {
|
|
224
|
+
if (item instanceof ListItemView) {
|
|
225
|
+
return item.children.first.isOn;
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
}));
|
|
251
229
|
}
|
|
252
|
-
|
|
253
230
|
/**
|
|
254
231
|
* A helper to be used on an existing {@link module:ui/dropdown/dropdownview~DropdownView} that focuses
|
|
255
232
|
* a specific child in DOM when the dropdown {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}.
|
|
@@ -260,159 +237,133 @@ export function addListToDropdown( dropdownView, items ) {
|
|
|
260
237
|
* If falsy value is returned, a default behavior of the dropdown will engage focusing the first focusable child in
|
|
261
238
|
* the {@link module:ui/dropdown/dropdownview~DropdownView#panelView}.
|
|
262
239
|
*/
|
|
263
|
-
export function focusChildOnDropdownOpen(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// * Let the panel show up first (do not focus an invisible element).
|
|
293
|
-
// * Execute after focusDropdownPanelOnOpen(). See focusDropdownPanelOnOpen() to learn more.
|
|
294
|
-
}, { priority: priorities.low - 10 } );
|
|
240
|
+
export function focusChildOnDropdownOpen(dropdownView, childSelectorCallback) {
|
|
241
|
+
dropdownView.on('change:isOpen', () => {
|
|
242
|
+
if (!dropdownView.isOpen) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const childToFocus = childSelectorCallback();
|
|
246
|
+
if (!childToFocus) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (typeof childToFocus.focus === 'function') {
|
|
250
|
+
childToFocus.focus();
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
/**
|
|
254
|
+
* The child view of a {@link module:ui/dropdown/dropdownview~DropdownView dropdown} is missing the `focus()` method
|
|
255
|
+
* and could not be focused when the dropdown got {@link module:ui/dropdown/dropdownview~DropdownView#isOpen open}.
|
|
256
|
+
*
|
|
257
|
+
* Making the content of a dropdown focusable in this case greatly improves the accessibility. Please make the view instance
|
|
258
|
+
* implements the {@link module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable focusable interface} for the best user
|
|
259
|
+
* experience.
|
|
260
|
+
*
|
|
261
|
+
* @error ui-dropdown-focus-child-on-open-child-missing-focus
|
|
262
|
+
* @param {module:ui/view~View} view
|
|
263
|
+
*/
|
|
264
|
+
logWarning('ui-dropdown-focus-child-on-open-child-missing-focus', { view: childToFocus });
|
|
265
|
+
}
|
|
266
|
+
// * Let the panel show up first (do not focus an invisible element).
|
|
267
|
+
// * Execute after focusDropdownPanelOnOpen(). See focusDropdownPanelOnOpen() to learn more.
|
|
268
|
+
}, { priority: priorities.low - 10 });
|
|
295
269
|
}
|
|
296
|
-
|
|
297
270
|
// Add a set of default behaviors to dropdown view.
|
|
298
271
|
//
|
|
299
272
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
300
|
-
function addDefaultBehavior(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
273
|
+
function addDefaultBehavior(dropdownView) {
|
|
274
|
+
closeDropdownOnClickOutside(dropdownView);
|
|
275
|
+
closeDropdownOnExecute(dropdownView);
|
|
276
|
+
closeDropdownOnBlur(dropdownView);
|
|
277
|
+
focusDropdownContentsOnArrows(dropdownView);
|
|
278
|
+
focusDropdownButtonOnClose(dropdownView);
|
|
279
|
+
focusDropdownPanelOnOpen(dropdownView);
|
|
307
280
|
}
|
|
308
|
-
|
|
309
281
|
// Adds a behavior to a dropdownView that closes opened dropdown when user clicks outside the dropdown.
|
|
310
282
|
//
|
|
311
283
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
312
|
-
function closeDropdownOnClickOutside(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
284
|
+
function closeDropdownOnClickOutside(dropdownView) {
|
|
285
|
+
dropdownView.on('render', () => {
|
|
286
|
+
clickOutsideHandler({
|
|
287
|
+
emitter: dropdownView,
|
|
288
|
+
activator: () => dropdownView.isOpen,
|
|
289
|
+
callback: () => {
|
|
290
|
+
dropdownView.isOpen = false;
|
|
291
|
+
},
|
|
292
|
+
contextElements: [dropdownView.element]
|
|
293
|
+
});
|
|
294
|
+
});
|
|
323
295
|
}
|
|
324
|
-
|
|
325
296
|
// Adds a behavior to a dropdownView that closes the dropdown view on "execute" event.
|
|
326
297
|
//
|
|
327
298
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
328
|
-
function closeDropdownOnExecute(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
} );
|
|
299
|
+
function closeDropdownOnExecute(dropdownView) {
|
|
300
|
+
// Close the dropdown when one of the list items has been executed.
|
|
301
|
+
dropdownView.on('execute', evt => {
|
|
302
|
+
// Toggling a switch button view should not close the dropdown.
|
|
303
|
+
if (evt.source instanceof SwitchButtonView) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
dropdownView.isOpen = false;
|
|
307
|
+
});
|
|
338
308
|
}
|
|
339
|
-
|
|
340
309
|
// Adds a behavior to a dropdown view that closes opened dropdown when it loses focus.
|
|
341
310
|
//
|
|
342
311
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
343
|
-
function closeDropdownOnBlur(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
312
|
+
function closeDropdownOnBlur(dropdownView) {
|
|
313
|
+
dropdownView.focusTracker.on('change:isFocused', (evt, name, isFocused) => {
|
|
314
|
+
if (dropdownView.isOpen && !isFocused) {
|
|
315
|
+
dropdownView.isOpen = false;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
349
318
|
}
|
|
350
|
-
|
|
351
319
|
// Adds a behavior to a dropdownView that focuses the dropdown's panel view contents on keystrokes.
|
|
352
320
|
//
|
|
353
321
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
354
|
-
function focusDropdownContentsOnArrows(
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
} );
|
|
322
|
+
function focusDropdownContentsOnArrows(dropdownView) {
|
|
323
|
+
// If the dropdown panel is already open, the arrow down key should focus the first child of the #panelView.
|
|
324
|
+
dropdownView.keystrokes.set('arrowdown', (data, cancel) => {
|
|
325
|
+
if (dropdownView.isOpen) {
|
|
326
|
+
dropdownView.panelView.focus();
|
|
327
|
+
cancel();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
// If the dropdown panel is already open, the arrow up key should focus the last child of the #panelView.
|
|
331
|
+
dropdownView.keystrokes.set('arrowup', (data, cancel) => {
|
|
332
|
+
if (dropdownView.isOpen) {
|
|
333
|
+
dropdownView.panelView.focusLast();
|
|
334
|
+
cancel();
|
|
335
|
+
}
|
|
336
|
+
});
|
|
370
337
|
}
|
|
371
|
-
|
|
372
338
|
// Adds a behavior that focuses the #buttonView when the dropdown was closed but focus was within the #panelView element.
|
|
373
339
|
// This makes sure the focus is never lost.
|
|
374
340
|
//
|
|
375
341
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
376
|
-
function focusDropdownButtonOnClose(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
} );
|
|
342
|
+
function focusDropdownButtonOnClose(dropdownView) {
|
|
343
|
+
dropdownView.on('change:isOpen', (evt, name, isOpen) => {
|
|
344
|
+
if (isOpen) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
// If the dropdown was closed, move the focus back to the button (#12125).
|
|
348
|
+
// Don't touch the focus, if it moved somewhere else (e.g. moved to the editing root on #execute) (#12178).
|
|
349
|
+
// Note: Don't use the state of the DropdownView#focusTracker here. It fires #blur with the timeout.
|
|
350
|
+
if (dropdownView.panelView.element.contains(global.document.activeElement)) {
|
|
351
|
+
dropdownView.buttonView.focus();
|
|
352
|
+
}
|
|
353
|
+
});
|
|
389
354
|
}
|
|
390
|
-
|
|
391
355
|
// Adds a behavior that focuses the #panelView when dropdown gets open (accessibility).
|
|
392
356
|
//
|
|
393
357
|
// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
|
|
394
|
-
function focusDropdownPanelOnOpen(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
// focus of a specific child by kicking in too late and resetting the focus in the panel.
|
|
406
|
-
}, { priority: 'low' } );
|
|
358
|
+
function focusDropdownPanelOnOpen(dropdownView) {
|
|
359
|
+
dropdownView.on('change:isOpen', (evt, name, isOpen) => {
|
|
360
|
+
if (!isOpen) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
// Focus the first item in the dropdown when the dropdown opened.
|
|
364
|
+
dropdownView.panelView.focus();
|
|
365
|
+
// * Let the panel show up first (do not focus an invisible element).
|
|
366
|
+
// * Also, execute before focusChildOnDropdownOpen() to make sure this helper does not break the
|
|
367
|
+
// focus of a specific child by kicking in too late and resetting the focus in the panel.
|
|
368
|
+
}, { priority: 'low' });
|
|
407
369
|
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* A definition of the list item used by the {@link module:ui/dropdown/utils~addListToDropdown}
|
|
411
|
-
* utility.
|
|
412
|
-
*
|
|
413
|
-
* @typedef {Object} module:ui/dropdown/utils~ListDropdownItemDefinition
|
|
414
|
-
*
|
|
415
|
-
* @property {String} type Either `'separator'`, `'button'` or `'switchbutton'`.
|
|
416
|
-
* @property {module:ui/model~Model} [model] Model of the item (when **not** `'separator'`).
|
|
417
|
-
* Its properties fuel the newly created list item (or its children, depending on the `type`).
|
|
418
|
-
*/
|