Opened 3 years ago

Closed 3 years ago

#14850 closed Bug (invalid)

eventProcessors for radio and checkbox UI element definitions overwritten

Reported by: AlexW Owned by:
Priority: Normal Milestone:
Component: UI : Dialogs Version:
Keywords: Cc:

Description

https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/dialogui/plugin.js#L1217 https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/dialogui/plugin.js#L1291

At those lines the ui element definition is extended to provide a new onChange function but this causes the default onShow, onHide and onLoad events to be lost.

  type: 'radio',
  items: [['One', 1], ['Two', 2], ['Three', 3]],
  'default': 1,
  onLoad: function() {
    //Never gets called.
  },

Should this be done in the same way as it is for button? https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/dialogui/plugin.js#L952

Change History (3)

comment:1 Changed 3 years ago by Jakub Ś

Status: newpending
Version: 4.5.11

I believe it was done like that on purpose. Both radio and checkbox are pretty simple elements. You can set their state when elements loads and all action is performed when you check/uncheck them.

Could you explain why do you need these other methods for checkbox and radio?

comment:2 Changed 3 years ago by AlexW

I tried to use onLoad to initially disable some of the radio buttons as they would be enabled by other elements.

I've since changed my widget so if it's newly inserted it sets some initial default options which make my dialog function as intended. Just wasn't sure if those events should be fired or not.

comment:3 Changed 3 years ago by Jakub Ś

Resolution: invalid
Status: pendingclosed

Thank you for the follow up. From what we have checked, removal of other events was done on purpose due to simplicity of the component.

Please also note that besides setting checkboxes and radio buttons manually, you can use the default property to set or unset them.

{
	type: 'checkbox',
	id: 'loop',
	label: editor.lang.flash.chkLoop,
	'default': true,
	setup: loadValue,
	commit: commitValue
},

{
	type: 'radio',
	id: 'country',
	label: 'Which country is bigger',
	items: [ [ 'France', 'FR' ], [ 'Germany', 'DE' ] ],
	style: 'color: green',
	'default': 'DE',
	onClick: function() {
		// this = CKEDITOR.ui.dialog.radio
		alert( 'Current value: ' + this.getValue() );
	}
}
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy