Skip to content

Commit 2564239

Browse files
committed
chore: Add private method documentation.
Addresses a review comment.
1 parent e9ea69d commit 2564239

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

core/focus_manager.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ export class FocusManager {
323323
};
324324
}
325325

326+
/**
327+
* Ensures that the manager is currently allowing operations that change its
328+
* internal focus state (such as via focusNode()).
329+
*
330+
* If the manager is currently not allowing state changes, an exception is
331+
* thrown.
332+
*/
326333
private ensureManagerIsUnlocked(): void {
327334
if (this.lockFocusStateChanges) {
328335
throw Error(
@@ -332,6 +339,10 @@ export class FocusManager {
332339
}
333340
}
334341

342+
/**
343+
* Defocuses the current actively focused node tracked by the manager, if
344+
* there is one iff the manager isn't in an ephemeral focus state.
345+
*/
335346
private defocusCurrentFocusedNode(): void {
336347
// The current node will likely be defocused while ephemeral focus is held,
337348
// but internal manager state shouldn't change since the node should be
@@ -342,6 +353,18 @@ export class FocusManager {
342353
}
343354
}
344355

356+
/**
357+
* Marks the specified node as actively focused, also calling related lifecycle
358+
* callback methods for both the node and its parent tree. This ensures that
359+
* the node is properly styled to indicate its active focus.
360+
*
361+
* This does not change the manager's currently tracked node, nor does it
362+
* change any other nodes.
363+
*
364+
* @param node The node to be actively focused.
365+
* @param prevTree The tree of the previously actively focused node, or null
366+
* if there wasn't a previously actively focused node.
367+
*/
345368
private activelyFocusNode(
346369
node: IFocusableNode,
347370
prevTree: IFocusableTree | null,
@@ -359,6 +382,18 @@ export class FocusManager {
359382
node.getFocusableElement().focus();
360383
}
361384

385+
/**
386+
* Marks the specified node as passively focused, also calling related
387+
* lifecycle callback methods for both the node and its parent tree. This
388+
* ensures that the node is properly styled to indicate its passive focus.
389+
*
390+
* This does not change the manager's currently tracked node, nor does it
391+
* change any other nodes.
392+
*
393+
* @param node The node to be passively focused.
394+
* @param nextTree The tree of the node receiving active focus, or null if no
395+
* node will be actively focused.
396+
*/
362397
private passivelyFocusNode(
363398
node: IFocusableNode,
364399
nextTree: IFocusableTree | null,
@@ -371,18 +406,36 @@ export class FocusManager {
371406
this.setNodeToVisualPassiveFocus(node);
372407
}
373408

409+
/**
410+
* Updates the node's styling to indicate that it should have an active focus
411+
* indicator.
412+
*
413+
* @param node The node to be styled for active focus.
414+
*/
374415
private setNodeToVisualActiveFocus(node: IFocusableNode): void {
375416
const element = node.getFocusableElement();
376417
dom.addClass(element, FocusManager.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);
377418
dom.removeClass(element, FocusManager.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME);
378419
}
379420

421+
/**
422+
* Updates the node's styling to indicate that it should have a passive focus
423+
* indicator.
424+
*
425+
* @param node The node to be styled for passive focus.
426+
*/
380427
private setNodeToVisualPassiveFocus(node: IFocusableNode): void {
381428
const element = node.getFocusableElement();
382429
dom.removeClass(element, FocusManager.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);
383430
dom.addClass(element, FocusManager.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME);
384431
}
385432

433+
/**
434+
* Removes any active/passive indicators for the specified node.
435+
*
436+
* @param node The node which should have neither passive nor active focus
437+
* indication.
438+
*/
386439
private removeHighlight(node: IFocusableNode): void {
387440
const element = node.getFocusableElement();
388441
dom.removeClass(element, FocusManager.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);

0 commit comments

Comments
 (0)