Skip to content

Conversation

@Japleen-Kaur2409
Copy link
Contributor

Proposed Changes

  • Refactor GraphDropdown component from being a child of Graph to being a child of NavBar
  • Removed the current logic for controlling this using direct DOM manipulation, and refactored the code so that it is controlled entirely through React props/state.

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) X
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CircleCI checks have passed.
  • I have requested a review from a project maintainer.

import { CourseModal } from "../common/react_modal.js.jsx"
import { ExportModal } from "../common/export.js.jsx"
import { getProgram } from "../common/utils.js"
import { getPost } from "../common/utils.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is unrelated to this PR

setDropdownTimeouts(dropdownTimeouts.concat(timeout))
}

React.useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation at this line is incorrect

}

React.useEffect(() => {
const navGraph = document.querySelector("#nav-graph")
Copy link
Contributor

Choose a reason for hiding this comment

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

Part of your task is to remove DOM manipulation. This includes accessing DOM elements direction and manually adding callbacks (addEventListener, below). Instead, these callbacks should be managed by the React components themselves. Make sure you understand the existing behaviour (on master) so that you can replicate it with your changes.

data-testid={"test-graph-dropdown"}
style={{ left: graphTabLeft }}
style={{ left: graphTabLeft, top: "50px", zIndex: 1000
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Put the }} on the same line as the {{.

Also, in this file there is still direct DOM manipulation, which you should remove by handling the logic in the parent NavBar component.

- Switched CircleCI ImageMagick download to use http
- Modified CI config to take advantage of partial dependency caching and exploit parallelism when resolving/updating dependencies
- Migrate graph-related components (FocusBar, FocusTab, GraphDropdown, GraphFallback, Infobox, and Sidebar) from classes to functions
- Refactor GraphDropdown component from being a child of Graph to being a child of NavBar
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do another merge from master, as I've made a new release; after doing this merge, this entry should be moved into the "unreleased" section.

<a href="/graph">Graph</a>
{selected_page === "graph" && (
<GraphDropdown
showGraphDropdown={showGraphDropdown }
Copy link
Contributor

Choose a reason for hiding this comment

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

delete the extra space

}
}

clearAllTimeouts = timeoutName => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function no longer needs to take an argument (timeoutName is now unused)

<li id="nav-graph" className={isActive("graph")}>
<li
id="nav-graph"
className={`${isActive("graph")} show-dropdown-arrow`}
Copy link
Contributor

Choose a reason for hiding this comment

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

In the previous version of the code, it looks like show-dropdown-arrow only appeared when there is at least one graph option.

* NavBar component.
*/
export function NavBar({ selected_page, open_modal }) {
export function NavBar({ selected_page, open_modal, graphs = [], updateGraph}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

include a space before the }

* @param {bool} value
*/
const toggleFocusModal = value => {
const toggleFocusModal = (value => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert all of the changes in this file (these are all unrelated to the PR)

}

const filteredSearch = query => {
const filteredSearch = (query) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes in this file are unrelated to this PR

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.

2 participants