Skip to content

Commit

Permalink
Fix inline middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Apr 19, 2024
1 parent 232d9ae commit 42f8d0f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions packages/core/src/middleware/hide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use serde::{Deserialize, Serialize};
use crate::{
detect_overflow::{detect_overflow, DetectOverflowOptions},
types::{
Derivable, DerivableFn, Middleware, MiddlewareReturn, MiddlewareState,
Derivable, DerivableFn, ElementContext, Middleware, MiddlewareReturn, MiddlewareState,
MiddlewareWithOptions,
},
ElementContext,
};

fn get_side_offsets(overflow: SideObject, rect: &Rect) -> SideObject {
Expand Down
13 changes: 6 additions & 7 deletions packages/core/src/middleware/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ use floating_ui_utils::{
DefaultVirtualElement, ElementOrVirtual, Padding, Rect, Side,
};

use crate::{
types::{
Derivable, DerivableFn, Middleware, MiddlewareReturn, MiddlewareState,
MiddlewareWithOptions,
},
GetElementRectsArgs, Reset, ResetRects, ResetValue,
use crate::types::{
Derivable, DerivableFn, GetElementRectsArgs, Middleware, MiddlewareReturn, MiddlewareState,
MiddlewareWithOptions, Reset, ResetRects, ResetValue,
};

fn get_bounding_rect(rects: Vec<ClientRectObject>) -> Rect {
Expand All @@ -35,7 +32,7 @@ fn get_bounding_rect(rects: Vec<ClientRectObject>) -> Rect {
Rect {
x: min_x,
y: min_y,
width: max_x - min_y,
width: max_x - min_x,
height: max_y - min_y,
}
}
Expand Down Expand Up @@ -170,6 +167,8 @@ impl<'a, Element: Clone + 'static, Window: Clone> Middleware<Element, Window>
..
} = state;

// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a ClientRect's bounds,
// despite the event listener being triggered. A padding of 2 seems to handle this issue.
let padding = options.padding.unwrap_or(Padding::All(2.0));

let native_client_rects = platform
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/middleware/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use crate::{
detect_overflow::{detect_overflow, DetectOverflowOptions},
types::{
Derivable, DerivableFn, Middleware, MiddlewareReturn, MiddlewareState,
MiddlewareWithOptions,
MiddlewareWithOptions, ResetRects, ResetValue,
},
ResetRects, ResetValue,
};

use super::SHIFT_NAME;
Expand Down

0 comments on commit 42f8d0f

Please sign in to comment.