Avoid text field from getting focus when calling setValueOf for CKEditor dialog plugin

153 Views Asked by At

I have a CKEditor dialog plugin as follow

CKEDITOR.dialog.add('myDialog', function( editor ) {

    editor.on( 'dialogShow', function( dialogShowEvent )
    {
        ...
        dialog.setValueOf('tab-xxx', 'seperator', ", ");

    });

    return {
        title: 'xxx',
        minWidth: 200,
        minHeight: 100,

        contents: [
            {
                id: 'tab-xxx',
                label: 'xxx',
                elements: [
                {
                    type: 'text',
                    id: 'seperator',
                    label: 'xxx'
                }]
            }
        ],

When dialog.setValueOf is being performed on text field, it will get focus automatically. This caused the entire value being selected.

enter image description here

I wish to avoid my newly inserted value, being selected. I had tried to shift the focus to other UI component

CKEDITOR.dialog.add('myDialog', function( editor ) {

    editor.on( 'dialogShow', function( dialogShowEvent )
    {
        ...
        dialog.setValueOf('tab-xxx', 'seperator', ", ");
        // Shift the focus, hopefully the text in 'seperator' will not be selected.
        dialog._.buttons['ok'].focus();            
    });

However, that doesn't help. May I know what is the correct approach to do so?

0

There are 0 best solutions below