Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 35 additions & 21 deletions packages/extension/src/components/option/SettingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ import { toCommandTree, toFlatten } from "@/services/option/commandTree"
import { isCommand, removeUnstoredParam } from "@/services/option/commandUtils"
import { enhancedSettings } from "@/services/settings/enhancedSettings"
import { Settings } from "@/services/settings/settings"
import DefaultSettings from "@/services/option/defaultSettings"
import DefaultSettings, {
emptySettings,
} from "@/services/option/defaultSettings"

import {
commandSchema,
Expand Down Expand Up @@ -122,6 +124,17 @@ export function SettingForm({ className }: { className?: string }) {
const form = useForm<FormValues>({
resolver: zodResolver(formSchema),
mode: "onChange",
defaultValues: {
startupMethod: emptySettings.startupMethod,
popupPlacement: emptySettings.popupPlacement,
style: emptySettings.style,
commands: [], // Empty array to avoid type conflicts
folders: emptySettings.folders,
linkCommand: emptySettings.linkCommand,
pageRules: emptySettings.pageRules,
userStyles: emptySettings.userStyles,
shortcuts: emptySettings.shortcuts,
},
})
const { reset, getValues, setValue, register, subscribe } = form

Expand Down Expand Up @@ -157,7 +170,8 @@ export function SettingForm({ className }: { className?: string }) {
const updateFormSettings = async () => {
isLoadingRef.current = true
const settings = await loadSettingsData()
reset(settings)
// Use reset with keepDefaultValues to maintain controlled behavior
reset(settings, { keepDefaultValues: false })
await sleep(100)
isLoadingRef.current = false
}
Expand Down Expand Up @@ -524,25 +538,25 @@ export function SettingForm({ className }: { className?: string }) {
)}
{linkCommandMethod ===
LINK_COMMAND_STARTUP_METHOD.LEFT_CLICK_HOLD && (
<InputField
control={form.control}
name="linkCommand.startupMethod.leftClickHoldParam"
formLabel={t("linkCommandStartupMethod_leftClickHoldParam")}
description={t(
"linkCommandStartupMethod_leftClickHoldParam_desc",
)}
unit="ms"
inputProps={{
type: "number",
min: 50,
max: 500,
step: 10,
...register("linkCommand.startupMethod.leftClickHoldParam", {
valueAsNumber: true,
}),
}}
/>
)}
<InputField
control={form.control}
name="linkCommand.startupMethod.leftClickHoldParam"
formLabel={t("linkCommandStartupMethod_leftClickHoldParam")}
description={t(
"linkCommandStartupMethod_leftClickHoldParam_desc",
)}
unit="ms"
inputProps={{
type: "number",
min: 50,
max: 500,
step: 10,
...register("linkCommand.startupMethod.leftClickHoldParam", {
valueAsNumber: true,
}),
}}
/>
)}
<SwitchField
control={form.control}
name="linkCommand.showIndicator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export const BackgroundPageActionDispatcher = {
{} as Record<string, string>,
) || {}),
}
let value = safeInterpolate(param.value, variables)
value = value.replace(/{/g, "{{") // escape

const value = safeInterpolate(param.value, variables)

if (!isEmpty(value)) {
// Direct value assignment for background tabs
Expand Down
8 changes: 4 additions & 4 deletions packages/extension/src/services/pageAction/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export namespace PageAction {

export type Click = {
type:
| PAGE_ACTION_EVENT.click
| PAGE_ACTION_EVENT.doubleClick
| PAGE_ACTION_EVENT.tripleClick
| PAGE_ACTION_EVENT.click
| PAGE_ACTION_EVENT.doubleClick
| PAGE_ACTION_EVENT.tripleClick
label: string
selector: string
selectorType: SelectorType
Expand Down Expand Up @@ -224,9 +224,9 @@ export const PageActionDispatcher = {
) || {}),
}
let value = safeInterpolate(param.value, variables)
value = value.replace(/{/g, "{{") // escape
if (!isEmpty(value)) {
if (!isEditable(element)) {
value = value.replace(/{/g, "{{") // escape
await user.type(element, value, { skipClick: true })
} else {
/*
Expand Down
Loading