Skip to content

Commit fb6dea7

Browse files
PR(2): Property Grid - Element Selector - A clicked element is not immediatelly selected (#6718)
* work for the #6685 * work for the #6685 * work for the #6685 * work for the #6685 * Revert "work for the #6685" This reverts commit 49c8a53.
1 parent d9ada44 commit fb6dea7

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

functionalTests/designer/side-bar.ts

+51
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,55 @@ test("No Focus on open Property grid Mobile", async (t) => {
284284
await t.expect(Selector(".svc-question__adorner button[title='Open settings']").visible).ok();
285285
await t.click(Selector(".svc-question__adorner button[title='Open settings']"));
286286
await t.expect(Selector(".spg-question[data-name=name] input").focused).notOk();
287+
});
288+
289+
test("Element Selector: Column: Scroll", async (t) => {
290+
await t.resizeWindow(1920, 500);
291+
292+
const json = {
293+
"pages": [
294+
{
295+
"name": "page1",
296+
"elements": [
297+
{
298+
"type": "matrixdropdown",
299+
"name": "question1",
300+
"columns": [
301+
{
302+
"name": "Column 1"
303+
},
304+
{
305+
"name": "Column 2"
306+
},
307+
{
308+
"name": "Column 3"
309+
}
310+
],
311+
"choices": [
312+
1,
313+
2,
314+
3,
315+
4,
316+
5
317+
],
318+
"rows": [
319+
"Row 1",
320+
"Row 2"
321+
]
322+
}
323+
]
324+
}
325+
],
326+
"headerView": "advanced"
327+
};
328+
await setJSON(json);
329+
330+
const getQuestionTopPosition = await ClientFunction(() => {
331+
return Math.round(document.querySelector(".svc-question__content")!.getBoundingClientRect().top);
332+
});
333+
334+
await t
335+
.expect(getQuestionTopPosition()).eql(374)
336+
.click(Selector("#svd-grid-object-selector")).click(Selector(".svc-list__item").withText("Column 2"))
337+
.expect(getQuestionTopPosition()).eql(72);
287338
});

packages/survey-creator-core/src/creator-base.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ export class SurveyCreatorModel extends Base
28302830
clearTimeout(this.currentFocusTimeout);
28312831
this.currentFocusTimeout = setTimeout(() => {
28322832
this.currentFocusInterval = setInterval(() => {
2833-
const el = document.getElementById(selEl.id);
2833+
let el = this.getHtmlElementForScroll(selEl);
28342834
if (!!selEl && (focus || startEdit && (!selEl.hasTitle || selEl.isPanel))) {
28352835
if (!el || this.rootElement.getAnimations({ subtree: true }).filter((animation => animation.effect.getComputedTiming().activeDuration !== Infinity && (animation.pending || animation.playState !== "finished")))[0]) return;
28362836
clearInterval(this.currentFocusInterval);
@@ -2845,7 +2845,7 @@ export class SurveyCreatorModel extends Base
28452845
SurveyHelper.scrollIntoViewIfNeeded(el.parentElement ?? el, () => { return scrollIntoViewOptions; }, true);
28462846
}
28472847
}
2848-
if (!propertyName && el.parentElement) {
2848+
if (!propertyName && el.parentElement && selEl.getType() !== "matrixdropdowncolumn") {
28492849
let elToFocus: HTMLElement = (typeof (focus) === "string") ? el.parentElement.querySelector(focus) : el.parentElement;
28502850
elToFocus && elToFocus.focus({ preventScroll: true });
28512851
}
@@ -2860,9 +2860,19 @@ export class SurveyCreatorModel extends Base
28602860
}, 100);
28612861
}
28622862

2863+
private getHtmlElementForScroll(element: any): HTMLElement {
2864+
const id = element.getType() === "matrixdropdowncolumn" ? element.colOwner.id : element.id;
2865+
return document.getElementById(id);
2866+
}
2867+
28632868
private getSelectedSurveyElement(): IElement {
28642869
var sel: any = this.selectedElement;
28652870
if (!sel || sel.getType() == "survey") return null;
2871+
2872+
if (this.selectedElement.getType() === "matrixdropdowncolumn") {
2873+
return (<any>this.selectedElement);
2874+
}
2875+
28662876
return sel.isInteractiveDesignElement && sel.id ? sel : null;
28672877
}
28682878
private onSelectingElement(val: Base): Base {

0 commit comments

Comments
 (0)