Skip to content

Commit

Permalink
fix: qwik submit action from form (#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Mar 20, 2023
1 parent 1ef8366 commit e096f8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
9 changes: 6 additions & 3 deletions packages/qwik-city/runtime/src/server-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ Action.run() can only be called on the browser, for example when a user clicks a
form = input.target as HTMLFormElement;
data = new FormData(form);
if (
input.submitter instanceof HTMLInputElement ||
input.submitter instanceof HTMLButtonElement
(input.submitter instanceof HTMLInputElement ||
input.submitter instanceof HTMLButtonElement) &&
input.submitter.name
) {
data.append(input.submitter.name, input.submitter.value);
if (input.submitter.name) {
data.append(input.submitter.name, input.submitter.value);
}
}
} else {
data = input;
Expand Down
31 changes: 15 additions & 16 deletions packages/qwik/src/optimizer/src/plugins/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,21 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
},
};

if (buildMode === 'development') {
const qDevKey = 'globalThis.qDev';
const qInspectorKey = 'globalThis.qInspector';
const qSerializeKey = 'globalThis.qSerialize';
const qDev = viteConfig?.define?.[qDevKey] ?? true;
const qInspector = viteConfig?.define?.[qInspectorKey] ?? true;
const qSerialize = viteConfig?.define?.[qSerializeKey] ?? true;

updatedViteConfig.define = {
[qDevKey]: qDev,
[qInspectorKey]: qInspector,
[qSerializeKey]: qSerialize,
};
(globalThis as any).qDev = qDev;
(globalThis as any).qInspector = qInspector;
}
const isDevelopment = buildMode === 'development';
const qDevKey = 'globalThis.qDev';
const qInspectorKey = 'globalThis.qInspector';
const qSerializeKey = 'globalThis.qSerialize';
const qDev = viteConfig?.define?.[qDevKey] ?? isDevelopment;
const qInspector = viteConfig?.define?.[qInspectorKey] ?? isDevelopment;
const qSerialize = viteConfig?.define?.[qSerializeKey] ?? isDevelopment;

updatedViteConfig.define = {
[qDevKey]: qDev,
[qInspectorKey]: qInspector,
[qSerializeKey]: qSerialize,
};
(globalThis as any).qDev = qDev;
(globalThis as any).qInspector = qInspector;

if (opts.target === 'ssr') {
// SSR Build
Expand Down

0 comments on commit e096f8b

Please sign in to comment.