﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6671	Styles combo drop down list not refreshed	Gilles van den Hoven	Garry Yao	"'''Situation:'''[[BR]]
- CKEditor 3.4.2[[BR]]
- Custom styleset loaded[[BR]]
- removeFormatTags added to include (e.g. remove) block elements[[BR]]
[[BR]][[BR]]
'''Following configuration was used:'''[[BR]]
{{{
<textarea name=""editor1"" rows=""8"" cols=""60"">&lt;h1&gt;Initial value&lt;/h1&gt;</textarea>
<script type=""text/javascript"">//<![CDATA[
CKEDITOR.replace('editor1', {
		""language"": ""en"",
		""skin"": ""v2"",
		""width"": ""100%"",
		""height"": ""500"",
		""resize_enabled"": false,
		""baseHref"": ""http:\/\/127.0.0.1\/"",
		""forcePasteAsPlainText"": true, 
		""removePlugins"": ""elementspath"",
		""removeFormatTags"": ""b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var,h1,h2,h3,h4,h5,h6,hr"",
		""toolbarCanCollapse"": false,
		""stylesSet"": ""default:http:\/\/127.0.0.1\/\/rewrite.php\/cms\/ckeditor\/styles""
	});
//]]></script>

}}}
[[BR]]
'''The loaded styleset:'''
{{{
CKEDITOR.stylesSet.add('default', [ { name: 'CMS - Accordeon titel element', element: 'div', attributes: { 'class': 'wuaTitle' } }, { name: 'Koptekst 1', element: 'h1' }, { name: 'Koptekst 2', element: 'h2' }, { name: 'Koptekst 3', element: 'h3' }, { name: 'Koptekst 4', element: 'h4' }, { name: 'Koptekst 5', element: 'h5' }, { name: 'Koptekst 6', element: 'h6' } ]);
}}}
[[BR]]
'''BUG description:'''[[BR]]
- Select the entire tag[[BR]]
- Click on the removeFormat button[[BR]]
- This removes the H1, but leaves the style marked in the stylescombo.[[BR]]
- So the styles combo did not get refreshed/updated in FF 3.6.12.[[BR]]
[[BR]][[BR]]
'''Does NOT happen (e.g. behaviour is correct) when the H1 is wrapped in a container as shown below:'''[[BR]]
{{{
<textarea name=""editor1"" rows=""8"" cols=""60"">&lt;div&gt;&lt;h1&gt;Initial value&lt;/h1&gt;&lt;/div&gt;</textarea>
}}}
[[BR]]
'''Cause & sollution:'''[[BR]]
After searching and diggin into the code for a huge ammount of time..[[BR]]
It seems that after clicking the removeFormat button, the ""selectionChange"", attached in the stylescombo (onRender) is not fired.[[BR]]
Getting this event to fire (duplicating code from _source/plugins/tabletools/dialogs.js:525) was unsuccesfull.[[BR]]
I managed to get it working by doing the following 2 changes, but it could be nicer...[[BR]]
[[BR]]

'''./_source/plugins/stylescombo/plugins.js'''[[BR]]
{{{
onRender : function()
{
	function updateCombo( ev ) {
		var currentValue = this.getValue();
		var elementPath = ev.data.path,
		elements = elementPath.elements;

		// For each element into the elements path.
		for ( var i = 0, count = elements.length, element ; i < count ; i++ )
		{
			element = elements[i];

			// Check if the element is removable by any of
			// the styles.
			for ( var value in styles )
			{
				if ( styles[ value ].checkElementRemovable( element, true ) )
				{
					if ( value != currentValue )
						this.setValue( value );
					return;
				}
			}
		}

		// If no styles match, just empty it.
		this.setValue( '' );
	}

	editor.on( 'selectionChange', updateCombo, this);
	editor.on( 'removeFormat', updateCombo, this);
},
}}}
[[BR]]
'''./_source/plugins/stylescombo/plugins.js (line 120)'''[[BR]]
{{{
	editor.getSelection().selectRanges( ranges );
	editor.fire( 'removeFormat', { path : new CKEDITOR.dom.elementPath( editor.getSelection().getStartElement() ) } );
}}}
'''Sample URLs:'''[[BR]]
- Bug behavior [http://ckeditor.webunity.nl/index-3-4-2-nocontainer.php][[BR]]
- Correct behavior [http://ckeditor.webunity.nl/index-3-4-2-container.php][[BR]]
- Patched behavior [http://ckeditor.webunity.nl/index-3-4-2-patched.php][[BR]]
"	Bug	closed	Normal		UI : Floating Panel	3.0	fixed	IBM FF	gilles@… satya_minnekanti@…
