Skip to content

Commit b8348ed

Browse files
authored
Merge pull request #478 from upfluence/oc/DRA-2301
Added fix for captureClickOutside
2 parents f745e9a + 953ba84 commit b8348ed

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

addon/components/o-s-s/power-select.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class={{concat "margin-top-px-0 upf-power-select__dropdown " this.dropdownAddressableClass}}
3838
id={{this.portalId}}
3939
{{on "click" this.noop}}
40-
{{on-click-outside this.onClickOutside}}
40+
{{on-click-outside this.onClickOutside useCapture=@captureClickOutside}}
4141
>
4242
<:option as |item|>
4343
{{yield item to="option-item"}}
@@ -61,7 +61,7 @@
6161
class={{concat "margin-top-px-0 upf-power-select__dropdown " this.dropdownAddressableClass}}
6262
id={{this.portalId}}
6363
{{on "click" this.noop}}
64-
{{on-click-outside this.onClickOutside}}
64+
{{on-click-outside this.onClickOutside useCapture=@captureClickOutside}}
6565
>
6666
<:option as |item|>
6767
{{yield item to="option-item"}}

addon/components/o-s-s/private/base-dropdown.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { isTesting } from '@embroider/macros';
66

77
export interface BaseDropdownArgs {
88
focusOnOpen?: boolean;
9+
captureClickOutside?: boolean;
910
}
1011

1112
export default class OSSBaseDropdown<T extends BaseDropdownArgs> extends Component<T> {
@@ -40,7 +41,9 @@ export default class OSSBaseDropdown<T extends BaseDropdownArgs> extends Compone
4041

4142
@action
4243
onClickOutside(_: HTMLElement, event: MouseEvent): void {
43-
event.stopPropagation();
44+
if (!this.args.captureClickOutside || this.container.contains(event.target as HTMLElement)) {
45+
event.stopPropagation();
46+
}
4447
this.closeDropdown();
4548
}
4649

addon/components/o-s-s/select.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@enableKeyboard={{true}}
3333
id={{this.portalId}}
3434
class={{concat "margin-top-px-0 oss-select-container__dropdown " this.dropdownAddressableClass}}
35-
{{on-click-outside this.onClickOutside}}
35+
{{on-click-outside this.onClickOutside useCapture=@captureClickOutside}}
3636
{{on "click" this.noop}}
3737
>
3838
<:option as |item|>

0 commit comments

Comments
 (0)