Skip to content

Commit

Permalink
fix: remove 'latest-active' variant from RestoreFocusType
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarMuhamethanov committed Nov 7, 2024
1 parent 8ef9261 commit c07f29c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/vkui/src/lib/floating/types/component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type * as React from 'react';
import type { UseFloatingMiddlewaresBootstrapOptions } from '../useFloatingMiddlewaresBootstrap';
import type {
RestoreFocusType,
UseFloatingWithInteractionsProps,
UseFloatingWithInteractionsReturn,
} from '../useFloatingWithInteractions';
import { type RestoreFocusType } from '../useFloatingWithInteractions/types';
import type { OnPlacementChange } from './common';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export type {
UseFloatingWithInteractionsReturn,
} from './types';

export { type RestoreFocusType } from './types';

export { DEFAULT_TRIGGER } from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type ManualTriggerType = 'manual';

export type TriggerType = ManualTriggerType | InteractiveTriggerType | InteractiveTriggerType[];

export type RestoreFocusType = boolean | 'latest-active' | 'anchor-element' | HTMLElement;
export type RestoreFocusType = boolean | 'anchor-element' | HTMLElement;

export type ShownChangeReason =
| 'click-outside'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const useFloatingWithInteractions = <T extends HTMLElement = HTMLElement>
if (!restoreFocus) {
return false;

Check warning on line 235 in packages/vkui/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts

View check run for this annotation

Codecov / codecov/patch

packages/vkui/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts#L235

Added line #L235 was not covered by tests
}
if (restoreFocus === true || restoreFocus === 'latest-active') {
if (restoreFocus === true) {
return triggerOnFocus ? blockFocusRef.current : true;
} else if (restoreFocus === 'anchor-element') {
return refs.reference.current as HTMLElement;
Expand Down

0 comments on commit c07f29c

Please sign in to comment.