Skip to content

Commit

Permalink
fix: draggable component console css errors (#17781)
Browse files Browse the repository at this point in the history
* fix: draggable component console css errors

* chore: add try catch
  • Loading branch information
shafin-deriv authored Dec 10, 2024
1 parent 2c69df4 commit bc3f886
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/bot-web-ui/src/components/draggable/draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ const Draggable: React.FC<TDraggableProps> = ({
setIsDragging(false);
isResizing.current = false;
if (draggableContentBody?.style) {
Object.assign(draggableContentBody.style, previousStyle);
try {
Object.assign(draggableContentBody.style, previousStyle);
} catch {
// no need to handle this error
}
draggableContentBody.style.pointerEvents = previousPointerEvent ?? 'unset';
}
if (boundaryRef) {
Expand All @@ -196,7 +200,12 @@ const Draggable: React.FC<TDraggableProps> = ({
return (
<div
className={`draggable ${isDragging ? 'dragging' : ''}`}
style={{ position: 'absolute', top: position.y, left: position.x, zIndex }}
style={{
position: 'absolute',
top: typeof position.y === 'number' ? position.y : 0,
left: typeof position.x === 'number' ? position.x : 0,
zIndex: typeof zIndex === 'number' ? zIndex : 0,
}}
onMouseDown={() => calculateZindex({ setZIndex })}
onKeyDown={() => calculateZindex({ setZIndex })}
data-testid='dt_react_draggable'
Expand All @@ -206,7 +215,10 @@ const Draggable: React.FC<TDraggableProps> = ({
ref={draggableRef}
className='draggable-content'
data-testid='dt_react_draggable_content'
style={{ width: size.width, height: size.height }}
style={{
width: typeof size.width === 'number' ? size.width : 0,
height: typeof size.height === 'number' ? size.height : 0,
}}
>
<div
id='draggable-content__header'
Expand Down

0 comments on commit bc3f886

Please sign in to comment.