Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon/components/o-s-s/context-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@theme={{@theme}}
@square={{@square}}
@countDown={{@countDown}}
@suffixIcon={{if this.displayContextMenuPanel "fa-chevron-up" "fa-chevron-down"}}
{{did-insert this.registerMenuTrigger}}
{{on "click" this.toggleContextMenuPanel}}
...attributes
Expand Down
2 changes: 1 addition & 1 deletion addon/components/o-s-s/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ContextMenuItem = {
items?: ContextMenuItem[];
groupKey?: string;
rowRenderer?: ReturnType<typeof ensureSafeComponent>;
action: () => void | boolean;
action: (event?: MouseEvent) => void | boolean;
[key: string]: unknown;
};

Expand Down
4 changes: 2 additions & 2 deletions addon/components/o-s-s/context-menu/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export default class OSSContextMenuPanelComponent extends Component<OSSContextMe
}

@action
callAction(action: ContextMenuItem['action']): void {
const returnValue = action?.();
callAction(action: ContextMenuItem['action'], event?: MouseEvent): void {
const returnValue = action?.(event);
if (returnValue !== false) {
this.args.onClose?.();
}
Expand Down
21 changes: 20 additions & 1 deletion tests/integration/components/o-s-s/context-menu-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module('Integration | Component | o-s-s/context-menu', function (hooks) {
);
assert.dom('button i').hasClass('fa-circle-notch').hasClass('fa-spin');
this.set('loading', false);
assert.dom('button i').doesNotExist();
assert.dom('button i.fa-circle-notch').doesNotExist();
});

test('it accepts loadingOptions argument', async function (assert) {
Expand Down Expand Up @@ -125,6 +125,25 @@ module('Integration | Component | o-s-s/context-menu', function (hooks) {
});

module('When clicking on the button', function () {
test('it shows chevron-down when panel isclosed', async function (assert) {
this.items = [{ title: 'Item', action: () => {} }];
await render(
hbs`<OSS::ContextMenu @label={{this.label}} @items={{this.items}} data-control-name="context-menu"/>`
);
assert.dom('button i.fa-chevron-down').exists();
assert.dom('button i.fa-chevron-up').doesNotExist();
});

test('it shows chevron-up when panel is open', async function (assert) {
this.items = [{ title: 'Item', action: () => {} }];
await render(
hbs`<OSS::ContextMenu @label={{this.label}} @items={{this.items}} data-control-name="context-menu"/>`
);
await click('button');
assert.dom('button i.fa-chevron-up').exists();
assert.dom('button i.fa-chevron-down').doesNotExist();
});

test('it opens the panel', async function (assert) {
await render(hbs`<OSS::ContextMenu @label={{this.label}}
@onMenuOpened={{this.onOpenStub}}
Expand Down
Loading