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

Introduce behaviour prop object with reFocus prop #2161

Merged
merged 12 commits into from
Nov 4, 2024
Merged

Conversation

jitu5
Copy link
Contributor

@jitu5 jitu5 commented Oct 29, 2024

Description

Resolves kedro-org/vscode-kedro#126

This PR Introduce behaviour prop object with reFocus prop. When behaviour.reFocus is set to false in embedded mode and when user clicks on node it will not re-focus.

behaviour: { 
     reFocus: false, // default is true
}

Development notes

FlowChart component:

  • src/components/flowchart/flowchart.js: Refactored the conditions for redrawing nodes and edges to prevent unnecessary zooming when the metadata sidebar or code panel visibility changes, or when the clicked node changes without node refocusing.

State management updates:

QA Notes:

You can test new options prop in src/components/container.js as <App /> is the entry point or top level component for a standalone use case.

const Container = () => (
  <>
    <App
      options={{
        display: {
          globalNavigation: false,
          sidebar: false,
          metadataPanel: false,
        },
        behaviour: {
          reFocus: false,
        },
      }}
      data={getPipelineData()}
    />
  </>
);

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

jitu5 added 2 commits October 29, 2024 15:20
Signed-off-by: Jitendra Gundaniya <[email protected]>
@jitu5 jitu5 self-assigned this Oct 29, 2024
@jitu5 jitu5 added the Javascript Pull requests that update Javascript code label Oct 29, 2024
jitu5 and others added 3 commits October 29, 2024 15:43
@jitu5 jitu5 requested a review from Huongg October 29, 2024 20:03
@jitu5 jitu5 marked this pull request as ready for review October 30, 2024 13:54
Copy link
Contributor

@rashidakanchwala rashidakanchwala left a comment

Choose a reason for hiding this comment

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

lgtm! thanks

@@ -89,6 +89,7 @@ const combinedReducer = combineReducers({
// These props don't have any actions associated with them
display: createReducer(null),
dataSource: createReducer(null),
modeOptions: createReducer({}),
Copy link
Contributor

Choose a reason for hiding this comment

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

[Nit] modeOptions inside options seems a bit confusing to me. Was there any consideration of having reFocus inside display ? If not, was there any reason to separate this ?
What does mode mean here ?

Copy link
Contributor

@ravi-kumar-pilla ravi-kumar-pilla Oct 30, 2024

Choose a reason for hiding this comment

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

if we expand on how flowchart behaves, something like flowchartBehavior or something along those lines might give a better idea of what the key value is. For me modeOptions does not seem fitting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

hey since the stand-alone version primarily covers the flowchart, we might not need to specify 'flowchart.' Maybe something more general like behaviour, interaction, or interactionMode would work?

@ravi-kumar-pilla
Copy link
Contributor

Hi @jitu5 , Thanks for the PR. I left some comments around naming but the functionality looks good. Thank you

Signed-off-by: Jitendra Gundaniya <[email protected]>
Copy link
Contributor

@Huongg Huongg left a comment

Choose a reason for hiding this comment

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

I tested it and it's all working fine for me. I agree with @ravi-kumar-pilla on the modeFocus name as it can be a bit confusing when you read it. Perhaps something about behaviour or interaction would work well in this context @jitu5 ?

@@ -220,22 +220,28 @@ export class FlowChart extends Component {

if (changed('edges', 'nodes', 'layers', 'chartSize', 'clickedNode')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, it looks like this section of code is for different beahviour of the stand-alone app. Perhaps having a comment here could help clarify the purpose, so we'll have better context if we refactor this component in the future. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Huongg Not exactly, those condition is also being used in normal mode, but yes refactoring flowchart.js component will really help overall.

@jitu5
Copy link
Contributor Author

jitu5 commented Oct 31, 2024

I tested it and it's all working fine for me. I agree with @ravi-kumar-pilla on the modeFocus name as it can be a bit confusing when you read it. Perhaps something about behaviour or interaction would work well in this context @jitu5 ?

@Huongg

modeFocus

You mean modeOptions ? To avoid confusion we can think reFocus is one of the behaviours.

behaviour: { 
    reFocus: false, // default is true
}

@ravi-kumar-pilla @rashidakanchwala wdyt ?

@ravi-kumar-pilla
Copy link
Contributor

behaviour: { 
    reFocus: false, // default is true
}

Since this is a user facing key (though we document it) this should be very clear on what it does. For me behavior seems very generic. flowchartBehavior seems more appropriate. Considering if we expand on other behaviors, having a behavior key might introduce additional nesting. But I am fine with either. Thank you

@rashidakanchwala
Copy link
Contributor

behaviour: { 
    reFocus: false, // default is true
}

Since this is a user facing key (though we document it) this should be very clear on what it does. For me behavior seems very generic. flowchartBehavior seems more appropriate. Considering if we expand on other behaviors, having a behavior key might introduce additional nesting. But I am fine with either. Thank you

nesting won't be a problem as we do deepmerge anyway right, @jitu5 ?

@jitu5
Copy link
Contributor Author

jitu5 commented Nov 1, 2024

behaviour: { 
    reFocus: false, // default is true
}

Since this is a user facing key (though we document it) this should be very clear on what it does. For me behavior seems very generic. flowchartBehavior seems more appropriate. Considering if we expand on other behaviors, having a behavior key might introduce additional nesting. But I am fine with either. Thank you

nesting won't be a problem as we do deepmerge anyway right, @jitu5 ?

@rashidakanchwala Yes, we do deepmerge.

@jitu5 jitu5 changed the title Introduce modeOptions prop object with reFocus prop Introduce behaviour prop object with reFocus prop Nov 1, 2024
Signed-off-by: Jitendra Gundaniya <[email protected]>
@ravi-kumar-pilla ravi-kumar-pilla self-requested a review November 4, 2024 01:43
Copy link
Contributor

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Choose a reason for hiding this comment

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

Works well !! Thank you @jitu5

@jitu5 jitu5 merged commit 4ec409e into main Nov 4, 2024
24 checks passed
@jitu5 jitu5 deleted the feature/re-focus branch November 4, 2024 11:07
@jitu5 jitu5 mentioned this pull request Nov 20, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Viz flowchart re-focus on every click
4 participants