Skip to content

Commit

Permalink
fix: expose placement
Browse files Browse the repository at this point in the history
  • Loading branch information
megheaiulian committed Dec 16, 2021
1 parent 8e960fd commit 844d77e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cosmoz-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useFocus } from './use-focus';
const preventDefault = e => e.preventDefault(),
fevs = ['focusin', 'focusout'],
Content = host => {
usePosition({ anchor: host.anchor, host });
usePosition({ anchor: host.anchor, host, placement: host.placement });
return html` <style>
:host {
position: fixed;
Expand All @@ -17,7 +17,8 @@ const preventDefault = e => e.preventDefault(),
<slot></slot>`;
},
Dropdown = host => {
const { active, onFocus, onToggle } = useFocus(host),
const { placement } = host,
{ active, onFocus, onToggle } = useFocus(host),
anchor = useCallback(() => host.shadowRoot.querySelector('.anchor'), []);
useEffect(() => {
host.setAttribute('tabindex', '-1');
Expand All @@ -44,7 +45,7 @@ const preventDefault = e => e.preventDefault(),
</button>
</div>
${ active
? html` <cosmoz-dropdown-content .anchor=${ anchor } part="dropdown">
? html` <cosmoz-dropdown-content part="dropdown" .anchor=${ anchor } .placement=${ placement }>
<slot></slot>
</cosmoz-dropdown-content>`
: [] }
Expand Down

0 comments on commit 844d77e

Please # to comment.