Kaynağa Gözat

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

Aleksander Nowodzinski 5 yıl önce
ebeveyn
işleme
ee88d6daf3

+ 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 {