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

Refactor invenioSearchRangeFactory to avoid infinite loop #104

Open
ntarocco opened this issue Oct 4, 2017 · 0 comments
Open

Refactor invenioSearchRangeFactory to avoid infinite loop #104

ntarocco opened this issue Oct 4, 2017 · 0 comments

Comments

@ntarocco
Copy link
Contributor

ntarocco commented Oct 4, 2017

The invenioSearchRangeFactory.js contains a potential infinite loop, fixed with a code that can be improved with a deeper refactoring.

Description:
When the years range facet is modified by the user, the event brush and brushend are fired.
The function implementing the brushend listener is then calling a function updateBrushPosition to redraw the brush.
Unfortunately, this function is dispatching a brush event to complete the redrawing, as stated in the documentation (https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Controls.md#_brush). This creates an infinite loop.

Workaround
A workaround has been added with this commit: ff63e62
It basically adds checks before firing brush events by comparing the state of the previous user selection to the new one.

Refactoring needed
The code should be refactored by removing as much as possible global states, and should perform redraw actions only when it is really needed.

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

No branches or pull requests

2 participants