Skip to content

Commit

Permalink
refactor: update ShadowFocusMixin and typings
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Feb 10, 2022
1 parent 4dfba60 commit 7206f91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/field-base/src/delegate-focus-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
import { Constructor } from '@open-wc/dedupe-mixin';
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
import { TabindexMixinClass } from '@vaadin/component-base/src/tabindex-mixin.js';

/**
* A mixin to forward focus to an element in the light DOM.
*/
export declare function DelegateFocusMixin<T extends Constructor<HTMLElement>>(
base: T
): T & Constructor<DelegateFocusMixinClass> & Constructor<DisabledMixinClass> & Constructor<FocusMixinClass>;
): T &
Constructor<DelegateFocusMixinClass> &
Constructor<DisabledMixinClass> &
Constructor<FocusMixinClass> &
Constructor<TabindexMixinClass>;

export declare class DelegateFocusMixinClass {
/**
Expand Down
18 changes: 15 additions & 3 deletions packages/field-base/src/shadow-focus-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
import { DelegateFocusMixin } from './delegate-focus-mixin.js';

/**
Expand All @@ -13,10 +12,23 @@ import { DelegateFocusMixin } from './delegate-focus-mixin.js';
* @polymerMixin
* @mixes DelegateFocusMixin
* @mixes KeyboardMixin
* @mixes TabindexMixin
*/
export const ShadowFocusMixin = (superClass) =>
class ShadowFocusMixinClass extends TabindexMixin(DelegateFocusMixin(KeyboardMixin(superClass))) {
class ShadowFocusMixinClass extends DelegateFocusMixin(KeyboardMixin(superClass)) {
static get properties() {
return {
/**
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
*
* @protected
*/
tabindex: {
type: Number,
value: 0
}
};
}

/**
* Override an event listener from `KeyboardMixin`
* to prevent setting `focused` on Shift Tab.
Expand Down

0 comments on commit 7206f91

Please sign in to comment.