Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12886 closed Bug (invalid)

Selected value resets in case of drop downs.

Reported by: chithra Owned by:
Priority: Normal Milestone:
Component: Core : Selection Version:
Keywords: Cc:

Description

Issue: When we have multiple drop downs, selecting value in one drop down, resets value in earlier selected values of other drop downs.

Desired Behavior: Drop down value needs to be retained until manually changed.

Example: Custom Drop down 1: Countries Custom Drop down 2: States

Select Countries Value to : USA When I select States drop down value, countries drop down gets changed to title value. Please help.

One Another Reference: http://dev.ckeditor.com/ticket/12536

Attachments (1)

insertlabel.zip (1.2 KB) - added by Jakub Ś 9 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 9 years ago by chithra

Below ticket has opposite desired behavior, http://dev.ckeditor.com/ticket/12526

Would be great if this is customizable where users could configure whether the earlier selected values in drop downs need to be reset or retained.

When a value is selected in drop down, and when I click in text area, automatically drop value gets reset. This was not the case in case of 3.x versions of ckeditor. From 4.x, we started noticing this issue.

comment:2 Changed 9 years ago by chithra

Steps to Reproduce: URL: http://jsfiddle.net/0h6myegn/1/ Choose a value from custom drop down. Choose a value now from Styles/Format dropdown, automatically custom drop value is reset.

comment:3 Changed 9 years ago by Jakub Ś

Resolution: invalid
Status: newclosed
Version: 4.4.6

As explained in one of these tickets, each built-in dropdown has its own method that handles updating dropdown state on selectionChange event. You can check how these methods work.

Currently, it is designed the way that element and styles need to match exactly what is in dropdown. Only then dropdown style can reflect state of element. If your span has color and font-size while the dropdown only reflects spans with color - the dropdown will not be updated.
Of course there is no stopping you in implementing method that will only check partial styles. I believe similar (but a lot more of work would have to be put) could be done with templates text like {{my_var}} however I'm not completely sure if reflecting text is doable.

I have updated your jssfiddle http://jsfiddle.net/0h6myegn/18/. You can see how selectionChange can be handled. Additionally I have corrected applying styles to elements.

To sum up: most of it is how it works. Some of it can be altered. All the rest is reported: http://dev.ckeditor.com/ticket/12526, http://dev.ckeditor.com/ticket/9964. Taking all that into account, I'm closing this issue as invalid.

comment:4 Changed 9 years ago by chithra

Thank you so much for your response. Let me restate my issue again.

We are having a custom plugin, which has

  1. Two dropdowns
  2. One dialog window to input a numerical value
  3. A button to process the input of above 2 controls and insert as html into the editor content.

These controls are independent of text editor contents, meaning we don't deal with styles or formats or fonts which change the content.

Let me give you an example,

First drop down has 'Countries' say USA, India, England. Second drop down has 'Options' say Wins,Draw,Loses. Standard dialog Window which takes a numerical input. We will call this bid amount.

When the process button is clicked, the bid content will be inserted. Eg: USA Draw $10000

Problem we are facing currently: When I choose country, followed by options drop down, country drop down value is lost. When I click on Dialog window, again previous drop down values are lost. When we click on 'Process' button, none of the controls are returning values as they are reset.

I tried your suggestion: Captured drop down value using 'OnClick' event (val1), and later used 'selectionChange' event to set the value to the drop down as below.

onRender: function() {

editor.on( 'selectionChange', function( ev ) {

this.setValue( val1 ); editor.fire( 'saveSnapshot' ); return; }, this );

But this value disappears as soon as we open dialog window to input numerical value or when I navigate to the editor to edit contents. Tried as a workaround, but I am unable to retain values for the drop downs when dialog window is open.

This was not the case with earlier ck editor versions.

But as per standard html drop down, when we choose a value, it stays and options doesn't change unless we reload the page or manually we edit.

I do agree styles drop down, concatenation check is performed and it is the current expected behavior of ckeditor. But we cannot limit drop downs just to styles/fonts/formats.

Custom plugins are restricted now with this current ckeditor behavior. Would be great if an option is provided to retain the values irrespective of dialog window or drop down or any other input. Please let me know if you need any more clarifications.

comment:5 Changed 9 years ago by Jakub Ś

CKEditor dropdowns are mainly designed to interact with CKEditor (chnage/insert HTML) and not only to set values inside them. If however you really need it and you must create dropdown in editor toolbar (and not for example native dropdowns under editor) then there is a workaround for that:

Please see attached plugin and set below code in your HTML page:

var editor = CKEDITOR.replace( 'editor1', {		
	extraPlugins : 'insertlabel'
});

Plugin inserts labels (but you can comment out all insertion and leave just setting values in dropdowns) and sets last clicked value for the dropdown. Thanks to placeholder last value is always retained (rewritten in fact) on every selection change.

Hope this helps.

Changed 9 years ago by Jakub Ś

Attachment: insertlabel.zip added

comment:6 Changed 9 years ago by chithra

Thank you for your response. This does help our issue.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy