mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix(base): stabilize choices reference so Add option row does not flicker
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import { Stack, NumberInput, Select, Switch, Text } from "@mantine/core";
|
import { Stack, NumberInput, Select, Switch, Text } from "@mantine/core";
|
||||||
import {
|
import {
|
||||||
IBaseProperty,
|
IBaseProperty,
|
||||||
@@ -88,7 +88,7 @@ function SelectOptions({
|
|||||||
hideButtons?: boolean;
|
hideButtons?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const options = property.typeOptions as SelectTypeOptions | undefined;
|
const options = property.typeOptions as SelectTypeOptions | undefined;
|
||||||
const choices = options?.choices ?? [];
|
const choices = useMemo(() => options?.choices ?? [], [options?.choices]);
|
||||||
|
|
||||||
const handleSave = useCallback(
|
const handleSave = useCallback(
|
||||||
(newChoices: Choice[]) => {
|
(newChoices: Choice[]) => {
|
||||||
@@ -127,7 +127,7 @@ function StatusOptions({
|
|||||||
hideButtons?: boolean;
|
hideButtons?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const options = property.typeOptions as SelectTypeOptions | undefined;
|
const options = property.typeOptions as SelectTypeOptions | undefined;
|
||||||
const choices = options?.choices ?? [];
|
const choices = useMemo(() => options?.choices ?? [], [options?.choices]);
|
||||||
|
|
||||||
const handleSave = useCallback(
|
const handleSave = useCallback(
|
||||||
(newChoices: Choice[]) => {
|
(newChoices: Choice[]) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user