Skip to content

Commit

Permalink
Type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemelia committed Sep 27, 2024
1 parent 536f2d9 commit eb40ec8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions addon/components/freestyle-usage-controls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ export default class FreestyleUsageControls extends Component {
});
});

toggle = helper(([prop]: [keyof this]) => {
return () => {
const currentValue = get(this, prop) as boolean;
const newValue = !currentValue;
return set(this, prop, newValue as this[keyof this]);
};
});
toggle = helper(
([prop]: ['showNotes' | 'showLabels' | 'showCode' | 'showApi']) => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const component = this;
return () => {
const currentValue = get(component, prop) as boolean;
const newValue = !currentValue;
set(component, prop, newValue);
};
},
);

setFocusOnEnterKey = (ev: KeyboardEvent) => {
if (ev.key === 'Enter') {
Expand All @@ -72,7 +76,7 @@ export default class FreestyleUsageControls extends Component {

@action
setFocus(): void {
this.emberFreestyle.set('focus', this.focus);
this.emberFreestyle.focus = this.focus;
}

updateFocus = (ev: Event) => {
Expand Down

0 comments on commit eb40ec8

Please sign in to comment.