Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section visibility nuances #58

Closed
bpostlethwaite opened this issue Nov 13, 2017 · 8 comments
Closed

Section visibility nuances #58

bpostlethwaite opened this issue Nov 13, 2017 · 8 comments
Assignees

Comments

@bpostlethwaite
Copy link
Member

see #54 (comment)

Right now <Section> will hide itself when all of its attr children are not visible. Currently if you put non attr children in a <Section> it will show. However you could make the case that <Info> (for example) should not by default force <Section> to show since it is <Info> about non applicable (and hidden) fields.

We might be able to extend this argument to <MenuPanel> (CogMenu) as well. If CogMenu is always (or almost always) an advanced settings of the base fields in <Section> then it may not make sense to show it.

To resolve this we need to look at all the CogMenus in the workspace and figure out sane defaults.

@bpostlethwaite
Copy link
Member Author

Note that right now if you click legend HIDE the positioning field still shows up as MenuPanel triggers section visibility . We should turn that off and test.

@bpostlethwaite
Copy link
Member Author

bpostlethwaite commented Nov 19, 2017

<Section> is passing in its context to unpackPlotProps which may be different than the context received by the children. For example if you have a structure like this:

<TraceConnectedPanel />
    <Section />
        <LayoutConnectedField />

<Section> will only see TraceConnected context objects and unpackPlotProps will return a different value then what will be computed by its <LayoutConnectedField> child. This is really bad... since the visibility will be computed incorrectly.

This is blocking adding layout attributes inside a Tracepanel. For example boxgap and friends.

cc @alexcjohnson sorta stuck on this one. We may have to rethink the way visibility is handled...

@bpostlethwaite
Copy link
Member Author

https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076 Hmmm we may have to rethink our use of context period.

@bpostlethwaite
Copy link
Member Author

bpostlethwaite commented Nov 19, 2017

One way would be to also define defaultProps for the container attr like fullLayout or fullData. Then the <Section> will see that prop and could use it. This would be set on the higher order component like connectLayoutToPlot.

I'll investigate that.

@bpostlethwaite
Copy link
Member Author

So this is all <Section>s fault. We need to work around the fact that <Section> precomputes plotProps using the wrong context. This has 2 negative side effects.

First is that it just computes the wrong visibility for the field. Second, once it has computed the wrong plotProps the default behaviour of a connectToContainer component is to not recompute them but simply used the ones passes to it by <Section> (or whatever parent). This saves some computation for all the components nested in <Section> but bites us here.

One way to get around the visibility problem is with a modifyPlotProps function in the higher order component that wraps container nested fields. This has been used a bunch of other times to customize the behaviour of certain fields. To work around the second case we will need to signal to connectToContainer that it needs to recompute plotProps.

I am going to move some of the other simple exceptions to a shame.js file and add the layout-inside-trace <Gap> widgets in there as well. Once I have progressed further it will hopefully become more apparent what exceptions need to be refactored away.

@bpostlethwaite
Copy link
Member Author

bpostlethwaite commented Nov 19, 2017

Also re: shouldComponentUpdate and context. This is pretty bad overall but if we are clear that any non-Editor intermediary component that is inserted into the graph and wants to implement shouldComponentUpdate needs to check the Editor.revision number we should be ok. If it increases the component must update. Then whenever we change context we make sure the revision number is always incremented. The rudiments for this are already in place. See #61

bpostlethwaite added a commit that referenced this issue Nov 20, 2017
Instead of modifyPlotProps we have a more general supplyPlotProps. If
a supplyPlotProps is present it is run. Most implementations of
supplyPlotProps will run `unpackPlotProps` first and then alter
plotProps as necessary. However, this enables us to now alter `props`
and `context` _before_ running unpackPlotProps. This will allows us to
"fix" the problem of nested layout fields within a trace context. See
#58 (comment)
for background.
@bpostlethwaite
Copy link
Member Author

workaround here #91

bpostlethwaite added a commit that referenced this issue Nov 21, 2017
Instead of modifyPlotProps we have a more general supplyPlotProps. If
a supplyPlotProps is present it is run. Most implementations of
supplyPlotProps will run `unpackPlotProps` first and then alter
plotProps as necessary. However, this enables us to now alter `props`
and `context` _before_ running unpackPlotProps. This will allows us to
"fix" the problem of nested layout fields within a trace context. See
#58 (comment)
for background.
bpostlethwaite added a commit that referenced this issue Nov 21, 2017
Instead of modifyPlotProps we have a more general supplyPlotProps. If
a supplyPlotProps is present it is run. Most implementations of
supplyPlotProps will run `unpackPlotProps` first and then alter
plotProps as necessary. However, this enables us to now alter `props`
and `context` _before_ running unpackPlotProps. This will allows us to
"fix" the problem of nested layout fields within a trace context. See
#58 (comment)
for background.
@bpostlethwaite bpostlethwaite self-assigned this Nov 23, 2017
@bpostlethwaite
Copy link
Member Author

closed by #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant