浏览代码

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 );
 		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 );
 		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();
 			this.items.first.focus();
 		}
 		}
 	}
 	}
+
+	destroy() {
+		// Stop listening to all keystrokes when the view is destroyed.
+		this.keystrokes.destroy();
+	}
 }
 }
 
 
 class MyListItemView extends View {
 class MyListItemView extends View {