Przeglądaj źródła

Hide tooltip when text is empty.

Oskar Wróbel 8 lat temu
rodzic
commit
772003c3ce

+ 2 - 1
packages/ckeditor5-ui/src/tooltip/tooltipview.js

@@ -58,7 +58,8 @@ export default class TooltipView extends View {
 			attributes: {
 				class: [
 					'ck-tooltip',
-					bind.to( 'position', position => 'ck-tooltip_' + position )
+					bind.to( 'position', position => 'ck-tooltip_' + position ),
+					bind.to( 'text', value => !value ? 'ck-hidden' : '' )
 				]
 			},
 			children: [

+ 8 - 0
packages/ckeditor5-ui/tests/tooltip/tooltipview.js

@@ -44,6 +44,14 @@ describe( 'TooltipView', () => {
 		} );
 
 		describe( 'class', () => {
+			it( 'should react on view#text', () => {
+				expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.false;
+
+				view.text = '';
+
+				expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.true;
+			} );
+
 			it( 'should react on view#position', () => {
 				expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.false;
 				expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.true;