fix: 多tab panel切换异常问题

This commit is contained in:
林熠 2021-10-21 15:32:15 +08:00 committed by lihao.ylh
parent 614159d7b2
commit ed5b10cbf1
2 changed files with 17 additions and 5 deletions

View File

@ -172,8 +172,8 @@ export class Skeleton {
const isInFloatAreaPreferenceExists = this.editor?.getPreference()?.contains(panelNameKey, 'skeleton'); const isInFloatAreaPreferenceExists = this.editor?.getPreference()?.contains(panelNameKey, 'skeleton');
if (isInFloatAreaPreferenceExists) { if (isInFloatAreaPreferenceExists) {
const isInFloatAreaFromPreference = this.editor?.getPreference()?.get(panelNameKey, 'skeleton'); const isInFloatAreaFromPreference = this.editor?.getPreference()?.get(panelNameKey, 'skeleton');
const currentIsInFloatArea = panel?.isInFloatArea(); const isCurrentInFloatArea = panel?.isChildOfFloatArea();
if (isInFloatAreaFromPreference !== currentIsInFloatArea) { if (isInFloatAreaFromPreference !== isCurrentInFloatArea) {
this.toggleFloatStatus(panel); this.toggleFloatStatus(panel);
} }
} }

View File

@ -154,25 +154,37 @@ export default class Panel implements IWidget {
getContent() { getContent() {
return this.content; return this.content;
} }
/** /**
* check is current panel is in float area or not * check is current panel is in float area or not
* *
* @returns {boolean} * @returns {boolean}
* @memberof Panel * @memberof Panel
*/ */
isInFloatArea(): boolean { isChildOfFloatArea(): boolean {
return this.parent?.name === 'leftFloatArea'; return this.parent?.name === 'leftFloatArea';
} }
/**
* check is current panel is in fixed area or not
*
* @returns {boolean}
* @memberof Panel
*/
isChildOfFixedArea(): boolean {
return this.parent?.name === 'leftFixedArea';
}
setActive(flag: boolean) { setActive(flag: boolean) {
if (flag === this._actived) { if (flag === this._actived) {
// TODO: 如果移动到另外一个 container会有问题 // TODO: 如果移动到另外一个 container会有问题
return; return;
} }
if (flag) { if (flag) {
if (this.isInFloatArea()) { // 对于 Area 的直接 Child要专门处理 Float & Fixed 分组切换, 其他情况不需要
if (this.isChildOfFloatArea()) {
this.skeleton.leftFixedArea.container.unactiveAll(); this.skeleton.leftFixedArea.container.unactiveAll();
} else { } else if (this.isChildOfFixedArea()) {
this.skeleton.leftFloatArea.container.unactiveAll(); this.skeleton.leftFloatArea.container.unactiveAll();
} }
this._actived = true; this._actived = true;