Skip to content

Commit 231fd56

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 a3172a5 commit 231fd56

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
@@ -3108,7 +3108,7 @@ export class SurveyCreatorModel extends Base
31083108
clearTimeout(this.currentFocusTimeout);
31093109
this.currentFocusTimeout = setTimeout(() => {
31103110
this.currentFocusInterval = setInterval(() => {
3111-
const el = document.getElementById(selEl.id);
3111+
let el = this.getHtmlElementForScroll(selEl);
31123112
if (!!selEl && (focus || startEdit && (!selEl.hasTitle || selEl.isPanel))) {
31133113
if (!el || this.rootElement.getAnimations({ subtree: true }).filter((animation => animation.effect.getComputedTiming().activeDuration !== Infinity && (animation.pending || animation.playState !== "finished")))[0]) return;
31143114
clearInterval(this.currentFocusInterval);
@@ -3123,7 +3123,7 @@ export class SurveyCreatorModel extends Base
31233123
SurveyHelper.scrollIntoViewIfNeeded(el.parentElement ?? el, () => { return scrollIntoViewOptions; }, true);
31243124
}
31253125
}
3126-
if (!propertyName && el.parentElement) {
3126+
if (!propertyName && el.parentElement && selEl.getType() !== "matrixdropdowncolumn") {
31273127
let elToFocus: HTMLElement = (typeof (focus) === "string") ? el.parentElement.querySelector(focus) : el.parentElement;
31283128
elToFocus && elToFocus.focus({ preventScroll: true });
31293129
}
@@ -3138,9 +3138,19 @@ export class SurveyCreatorModel extends Base
31383138
}, 100);
31393139
}
31403140

3141+
private getHtmlElementForScroll(element: any): HTMLElement {
3142+
const id = element.getType() === "matrixdropdowncolumn" ? element.colOwner.id : element.id;
3143+
return document.getElementById(id);
3144+
}
3145+
31413146
private getSelectedSurveyElement(): IElement {
31423147
var sel: any = this.selectedElement;
31433148
if (!sel || sel.getType() == "survey") return null;
3149+
3150+
if (this.selectedElement.getType() === "matrixdropdowncolumn") {
3151+
return (<any>this.selectedElement);
3152+
}
3153+
31443154
return sel.isInteractiveDesignElement && sel.id ? sel : null;
31453155
}
31463156
private onSelectingElement(val: Base): Base {

0 commit comments

Comments
 (0)