Unhandled exception on "ctrl+left/right-click" drag or "shift+right-click" drag on a chart
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 18.3k
- フォーク
- 2k
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 28
説明
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
}
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Plotly のサンプルで、ctrl を押しながら左/右にドラッグするか、shift を押しながら右にドラッグして失敗を再現し、その後、issue に示されている onMove 関数と dragTail 関数を追跡します。undefined の更新を _guiRelayout に渡さずにドラッグが完了すること、また例外がコンソールに表示されなくなることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100