Преглед на файлове

Docs: Added KeystrokeHandler#destroy() to the snippets.

Aleksander Nowodzinski преди 5 години
родител
ревизия
ee88d6daf3
променени са 1 файла, в които са добавени 22 реда и са изтрити 0 реда
  1. 22 0
      packages/ckeditor5-ui/docs/framework/guides/deep-dive/focus-tracking.md

+ 22 - 0
packages/ckeditor5-ui/docs/framework/guides/deep-dive/focus-tracking.md

@@ -352,6 +352,11 @@ export default class MyListView extends View {
 		this.keystrokes.listenTo( this.element );
 	}
 
+	destroy() {
+		// Stop listening to all keystrokes when the view is destroyed.
+		this.keystrokes.destroy();
+	}
+
 	// ...
 }
 ```
@@ -439,6 +444,18 @@ class MyListView extends View {
 		this.keystrokes.listenTo( this.element );
 	}
 
+	focus() {
+		if ( this.items.length ) {
+			// This will call MyListItemView#focus().
+			this.items.first.focus();
+		}
+	}
+
+	destroy() {
+		// Stop listening to all keystrokes when the view is destroyed.
+		this.keystrokes.destroy();
+	}
+
 	// ...
 }
 ```
@@ -519,6 +536,11 @@ class MyListView extends View {
 			this.items.first.focus();
 		}
 	}
+
+	destroy() {
+		// Stop listening to all keystrokes when the view is destroyed.
+		this.keystrokes.destroy();
+	}
 }
 
 class MyListItemView extends View {