Skip to content

Commit

Permalink
Merge pull request writer#689 from writer/fix-float-coordinates
Browse files Browse the repository at this point in the history
fix: Float coordinates
  • Loading branch information
ramedina86 authored Dec 11, 2024
2 parents 00464b0 + 27b4e8a commit 96b3378
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "writer"
version = "0.8.3rc1"
version = "0.8.3rc2"
description = "An open-source, Python framework for building feature-rich apps that are fully integrated with the Writer platform."
authors = ["Writer, Inc."]
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/components/workflows/WorkflowsWorkflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ function moveNode(ev: MouseEvent) {
const component = wf.getComponentById(nodeId);
const { x, y } = getAdjustedCoordinates(ev);
const newX = x - offset.x;
const newY = y - offset.y;
const newX = Math.floor(x - offset.x);
const newY = Math.floor(y - offset.y);
if (component.x == newX && component.y == newY) return;
Expand Down
8 changes: 7 additions & 1 deletion src/writer/core_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from enum import Enum
from typing import Any, Dict, List, Literal, Optional, Union, cast

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, field_validator, validator
from typing_extensions import TypedDict

from writer.ss_types import ComponentDefinition, ServeMode
Expand Down Expand Up @@ -57,6 +57,12 @@ class Component(BaseModel):
x: Optional[int] = None
y: Optional[int] = None

@field_validator("x", "y", mode="before")
def cast_float_to_int(cls, v):
if isinstance(v, float):
return int(v)
return v

def to_dict(self) -> Dict:
"""
Wrapper for model_dump to ensure backward compatibility.
Expand Down

0 comments on commit 96b3378

Please sign in to comment.