File tree Expand file tree Collapse file tree
packages/ui/src/components/editor/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,13 @@ export const Dropdown = <T extends string>(props: Dropdown.Props<T>) => {
8989 ] ) }
9090 />
9191 </ button >
92- { is_open && < DropdownMenu items = { menu_items } /> }
92+ { is_open && (
93+ < DropdownMenu
94+ items = { menu_items }
95+ anchor_ref = { dropdown_ref }
96+ is_open = { is_open }
97+ />
98+ ) }
9399 </ div >
94100 )
95101}
Original file line number Diff line number Diff line change 66 z-index : 2 ;
77 width : max-content ;
88 text-align : left ;
9- min-width : max ( 100% , 110 px ) ;
9+ min-width : 100% ;
1010
1111 & __inner {
1212 background-color : var (--vscode-quickInput-background );
Original file line number Diff line number Diff line change @@ -38,17 +38,22 @@ export const DropdownMenu: React.FC<DropdownMenu.Props> = (props) => {
3838 const dropdown_rect = dropdown_ref . current . getBoundingClientRect ( )
3939
4040 let top = anchor_rect . bottom
41+ const actual_dropdown_width = Math . max (
42+ dropdown_rect . width ,
43+ anchor_rect . width
44+ )
45+
4146 let left = props . match_anchor_width
4247 ? anchor_rect . left
43- : anchor_rect . right - dropdown_rect . width
48+ : anchor_rect . right - actual_dropdown_width
4449 let width : string | undefined
4550
4651 if ( props . match_anchor_width ) {
4752 width = `${ anchor_rect . width } px`
4853 } else if ( left < 0 ) {
4954 left = 4
50- } else if ( left + dropdown_rect . width > window . innerWidth ) {
51- left = window . innerWidth - dropdown_rect . width - 4
55+ } else if ( left + actual_dropdown_width > window . innerWidth ) {
56+ left = window . innerWidth - actual_dropdown_width - 4
5257 }
5358
5459 const viewport_height = window . innerHeight
@@ -60,7 +65,8 @@ export const DropdownMenu: React.FC<DropdownMenu.Props> = (props) => {
6065 set_anchor_style ( {
6166 top : `${ top } px` ,
6267 left : `${ left } px` ,
63- width
68+ width,
69+ minWidth : `${ anchor_rect . width } px`
6470 } )
6571 } else if ( ! props . is_open ) {
6672 set_anchor_style ( { } )
You can’t perform that action at this time.
0 commit comments