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

Disallow instructions resize #30196

Merged
merged 6 commits into from
Aug 8, 2019
Merged

Conversation

davidsbailey
Copy link
Member

@davidsbailey davidsbailey commented Aug 7, 2019

finishes https://codedotorg.atlassian.net/browse/LP-533

Background

although the problem pictured in the bug report no longer repros exactly, a slight rendering glitch still exists when switching between spritelab Code and Costumes modes:

resize

The problematic sequence of events is:

  1. user clicks Costumes tab
  2. codeWorkspace and instructions are hidden via
    const codeModeStyle = {
    display: interfaceMode !== GameLabInterfaceMode.CODE ? 'none' : undefined
  3. TopInstructions re-renders to a smaller height
  4. due to change in size, CodeWorkspaceContainer (sibling of TopInstructions) fires a resize event:
    componentDidUpdate(prevProps) {
    if (this.props.topMargin !== prevProps.topMargin) {
    utils.fireResizeEvent();
    causing the workspace to re-render as empty
  5. user clicks Code tab

EXPECTED: blockly and instructions appear exactly as they were before
ACTUAL: instructions are the wrong size, and blockly workspace initially fails to appear

the above problem is exacerbated when we try to remove extraneous resize events from the tab-switching sequence, which can be seen in the screenshots in #28361 .

Description

This PR allows the application to specify whether the instructions pane is allowed to resize. SpriteLab and GameLab then disallow resizing while not in Code mode. This solves the problem and reliably gives the expected behavior listed above, even when stacked on top of #28294 (which is the one that led to the broken screenshots shown in #28361).

spritelab-instructions

Copy link
Contributor

@jmkulwik jmkulwik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change!

@@ -45,6 +46,9 @@ export function changeInterfaceMode(interfaceMode, spritelabDraw) {
dispatch(show(Goal.NEW_ANIMATION));
dispatch(pickNewAnimation());
}
dispatch(
setAllowInstructionsResize(interfaceMode === GameLabInterfaceMode.CODE)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just allow redux/instructions.js to respond to the CHANGE_INTERFACE_MODE action?

Pros: We push some more business logic down into redux. We don't introduce a new redux action that might not make sense to dispatch in isolation.

Cons: We entangle two redux modules? But not much, because the CHANGE_INTERFACE_MODE action is defined in this file, I think.
Con:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like where you're going with this, but I don't think we want to do exactly what you're suggesting because it doesn't make sense for the instructions redux to know which modes it should be visible in. For example, instructions are visible in applab when not in code mode.

If we wanted to improve our separation of concerns, one idea is that the GameLabView could set the isVisible prop on InstructionsWithWorkspace. InstructionsWithWorkspace would then use that information to set the allowResize prop on TopInstructions (and possibly also on CodeWorkspaceContainer if we someday want to make it stop triggering resize events).

one nuance is that I'm suggesting allowResize over hidden or visible in part because TopInstructions already has a hidden prop which means something different -- i.e. set height to zero, as opposed to temporarily disallow changing the height.

Does this seem worth doing now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're saying. I think it's fine to use your current solution and unblock starlabs. Thanks for talking through alternatives!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking on this a moment longer, there are 3 steps that would take us from the solution in this PR to the one I'm describing in the above comments:

  1. move responsibility for communicating with instructions from p5lab redux to GameLabView
  2. move understanding that "instructions are not visible" means "do not allow instructions resize" out of p5lab and into instructions
  3. change allowResize from redux to an explicitly passed prop

if we want to move in this direction, let's be deliberate about which of the above are important. if we only care about (2), for example, then we might only need to rename setAllowInstructionsResize to setIsInstructionsVisible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I missed your comment from a couple minutes ago. ok, merging as-is sounds good!

@davidsbailey davidsbailey merged commit 1f29d98 into staging Aug 8, 2019
@davidsbailey davidsbailey deleted the disallow-instructions-resize branch August 8, 2019 17:52
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (staging@1fd3c98). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             staging   #30196   +/-   ##
==========================================
  Coverage           ?   71.94%           
==========================================
  Files              ?     1368           
  Lines              ?    84496           
  Branches           ?     3408           
==========================================
  Hits               ?    60788           
  Misses             ?    20463           
  Partials           ?     3245
Flag Coverage Δ
#integration 55.5% <100%> (?)
#storybook 56.6% <75%> (?)
#unit 58.01% <88.88%> (?)
Impacted Files Coverage Δ
apps/src/redux/instructions.js 95.96% <100%> (ø)
apps/src/p5lab/actions.js 81.57% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fd3c98...52f25d5. Read the comment docs.

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

Successfully merging this pull request may close these issues.

None yet

4 participants