Skip to content

Commit

Permalink
fix: zoom should not update without change input value
Browse files Browse the repository at this point in the history
- close #188
  • Loading branch information
F-star committed Sep 30, 2024
1 parent e1636c1 commit 5d85c5e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const ZoomInput: FC<IProps> = ({ defaultValue, onChange }) => {
const [value, setValue] = useState(
defaultValue ? `${String(Math.round(defaultValue * 100))}%` : '',
);
const roundValueStr = defaultValue && Math.round(defaultValue * 100);

useMount(() => {
if (inputRef.current) {
Expand All @@ -23,8 +24,8 @@ export const ZoomInput: FC<IProps> = ({ defaultValue, onChange }) => {

const emitChange = () => {
const newZoom = parseInt(value);
if (!Number.isNaN(newZoom)) {
onChange && onChange(remainDecimal(newZoom / 100));
if (!Number.isNaN(newZoom) && roundValueStr !== newZoom && onChange) {
onChange(remainDecimal(newZoom / 100));
}
};

Expand Down

0 comments on commit 5d85c5e

Please sign in to comment.