Skip to content

Commit

Permalink
fix: suggestion position is wrong (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwtong committed Dec 18, 2021
1 parent c6a02c8 commit 3d16f46
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,19 @@ class Autocomplete extends React.Component<AutocompleteProps> {
left +
dropdownBounds.width;

if (dropdownRight > containerBounds.right) {
leftPosition = left - dropdownBounds.width;
usedClasses.push(POSITION_CONFIGURATION.X.LEFT);
unusedClasses.push(POSITION_CONFIGURATION.X.RIGHT);
} else {
leftPosition = left;
usedClasses.push(POSITION_CONFIGURATION.X.RIGHT);
unusedClasses.push(POSITION_CONFIGURATION.X.LEFT);
}
if (dropdownRight > containerBounds.right &&
textareaBounds.left + left > dropdownBounds.width) {
leftPosition = left - dropdownBounds.width;
usedClasses.push(POSITION_CONFIGURATION.X.LEFT);
unusedClasses.push(POSITION_CONFIGURATION.X.RIGHT);
} else {
leftPosition = left;
usedClasses.push(POSITION_CONFIGURATION.X.RIGHT);
unusedClasses.push(POSITION_CONFIGURATION.X.LEFT);
}

if (dropdownBottom > containerBounds.bottom) {
if (dropdownBottom > containerBounds.bottom &&
textareaBounds.top + top > dropdownBounds.height) {
topPosition = top - dropdownBounds.height;
usedClasses.push(POSITION_CONFIGURATION.Y.TOP);
unusedClasses.push(POSITION_CONFIGURATION.Y.BOTTOM);
Expand Down

0 comments on commit 3d16f46

Please sign in to comment.