Unhandled exception on "ctrl+left/right-click" drag or "shift+right-click" drag on a chart
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.3k
- Forks
- 2k
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 28
Descripción
On a chart if I hold ctrl and try to drag with left-click or right-click or shift+right-click drag, then getting an exception.
After analyzing the code, I found that ctrl is treated as right-click, and if drag operation and right click then "options.moveFn(dx, dy);" function is not getting called which results in not updating "updates" for the dragTail() function that calls "_guiRelayout" with undefined updates and in that function exception is raised if updates are undefined. Pasting js code of these function below:
This issue can be replicated easily in plotly's samples as well. Just hold ctrl and drag with left/right-click, you can see error in console.
Attaching snapshot:
function onMove(e) {
e.preventDefault();
var offset = pointerOffset(e);
var minDrag = options.minDrag || constants.MINDRAG;
var dxdy = clampFn(offset[0] - startX, offset[1] - startY, minDrag);
var dx = dxdy[0];
var dy = dxdy[1];
if (dx || dy) {
gd._dragged = true;
dragElement.unhover(gd);
}
if (gd._dragged && options.moveFn && !rightClick) {
gd._dragdata = {
element: element,
dx: dx,
dy: dy,
};
options.moveFn(dx, dy);
}
return;
}
// dragTail - finish a drag event with a redraw
function dragTail() {
// put the subplot viewboxes back to default (Because we're going to)
// be repositioning the data in the relayout. But DON'T call
// ticksAndAnnotations again - it's unnecessary and would overwrite `updates`
updateSubplots([0, 0, pw, ph]);
// since we may have been redrawing some things during the drag, we may have
// accumulated MathJax promises - wait for them before we relayout.
Lib.syncOrAsync(
[
Plots.previousPromises,
function () {
gd._fullLayout._replotting = false;
Registry.call("_guiRelayout", gd, updates);
},
],
gd
);
}
function relayout(gd, astr, val) {
gd = Lib.getGraphDiv(gd);
helpers.clearPromiseQueue(gd);
if (gd.framework && gd.framework.isPolar) {
return Promise.resolve(gd);
}
var aobj = {};
if (typeof astr === "string") {
aobj[astr] = val;
} else if (Lib.isPlainObject(astr)) {
aobj = Lib.extendFlat({}, astr);
} else {
Lib.warn("Relayout fail.", astr, val);
return Promise.reject(); // From here exception is raised
}
.... Rest of the code
}
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el fallo en las muestras de Plotly con ctrl más arrastre hacia la izquierda/derecha o shift más arrastre hacia la derecha, y luego sigue las funciones onMove y dragTail que se muestran en el issue. Verifica que el arrastre se complete sin pasar actualizaciones undefined a _guiRelayout y que la excepción ya no aparezca en la consola.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100