jared-hughes / DesThree

Desmos bindings for three.js
3 stars 0 forks source link

The "add expression" icon dissapears after an "edit list" toggle #53

Closed SlimRunner closed 3 years ago

SlimRunner commented 3 years ago

The three expression type in the add expression context menu stops showing up after toggling the edit list feature in Desmos once.

I went ahead and inspected elements and it seems the element referenced here: https://github.com/jared-hughes/DesThree/blob/13a791d65d95b6cf1f75a649772e1506713064e7/src/View.js#L18 for the MutationOverserver to keep track of the context menu gets removed/replaced by Desmos backend.

Maybe a slight modification to the observer could fix the issue. However, do note that this replacement/removal of nodes happens up to three parents above the element previously referenced when hiding and showing the expression panel. This means the safest option would be to track .dcg-exppanel-container with a following query to make sure the context menu has appeared.

jared-hughes commented 3 years ago

The MutationObserver method would work, but I just discovered the following:

Calc.controller.dispatcher.register(e => e.type === 'toggle-add-expression' && console.log(e)).

Absolutely incredible if it always executes after the dropdown list is made.