freesewing icon indicating copy to clipboard operation
freesewing copied to clipboard

[bug]: Octoplushy design crashes if changing armlength option (and others)

Open HaasJona opened this issue 1 year ago • 4 comments

What seems to be the problem? 🤔

Steps to reproduce:

  • new Octoplushy design
  • In the right bar, click on Design Options → Style → Arm length (no dragging required)

Actual result:

  • website turns white, error in Browser console:
Uncaught TypeError: options is undefined
    toAbs head.mjs:635
    PctOptionInput inputs.mjs:23
    React 16
    onClick accordion.mjs:54
    React 23
    renderReactElement index.tsx:582
    doRender index.tsx:795
    render index.tsx:824
    hydrate index.tsx:993
    pageBootrap page-bootstrap.ts:22
    <anonymous> next-dev.ts:21
    promise callback* next-dev.ts:20
    NextJS 7
head.mjs:635:9
    toAbs head.mjs:635
    PctOptionInput inputs.mjs:23
    React 16
    onClick accordion.mjs:54
    React 19
    forEach self-hosted:4304
    React 4
    renderReactElement index.tsx:582
    doRender index.tsx:795
    render index.tsx:824
    hydrate index.tsx:993
    AsyncFunctionNext self-hosted:807
    (Async: async)
    pageBootrap page-bootstrap.ts:22
    <anonym> next-dev.ts:21
    (Async: promise callback)
    <anonym> next-dev.ts:20
    NextJS 7

Expected result:

  • no crash

Design / Plugin / Package 🧐

designs/octoplushy

Additional context

Filing this under the Octoplushy component, but I suspect the actual issue might be in the FreeSewing core.

HaasJona avatar Sep 25 '24 08:09 HaasJona

There is a workaround:

  1. Change the Design Options->Style->Type to Octopus or Squid or change it back to Octoplushy.
  2. Go to Design Options->Style->Arm Length and change the setting.
  3. The bug does not occur.

BenJamesBen avatar Sep 25 '24 12:09 BenJamesBen

armLength: {
    pct: 200,
    min: 100,
    max: 500,
    menu: 'style',
    toAbs: (val, { options }, mergedOptions) =>
      ((mergedOptions.sizeConstant *
        (options.size === undefined ? mergedOptions.size : options.size) *
        2) /
        3.1415) *
      val *
      (options.type === undefined
        ? 1
        : options.type == 'octopus'
        ? 2
        : options.type == 'squid'
        ? 1.8
        : 1),
  },

I have a feeling that the options.type === undefined needs to be options.type === undefined || options.type == 'octoplushy' I think because it is defined as octoplushy when you first load in the armLength option can't run the merge.

bobgeorgethe3rd avatar Sep 25 '24 12:09 bobgeorgethe3rd

I don't understand how mergedOptions is supposed to work in our UI infrastructure. However, I note that I can get the bug to not appear via:

-- a/designs/octoplushy/src/head.mjs
+++ b/designs/octoplushy/src/head.mjs
@@ -618 +618 @@ const options = {
-      (options.type === undefined
+      (options === undefined || options.type === undefined
@@ -635 +635 @@ const options = {
-        (options.size === undefined ? mergedOptions.size : options.size) *
+        (options === undefined || options.size === undefined ? mergedOptions.size : options.size) *
@@ -639 +639 @@ const options = {
-      (options.type === undefined
+      (options === undefined || options.type === undefined

BenJamesBen avatar Sep 25 '24 12:09 BenJamesBen

The Size option has the same problem.

woutervdub avatar Sep 26 '24 04:09 woutervdub