mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
fix: recreate dropdown div (#7572)
* fix: recreate dropdown div
* fix: recreate tooltip div
* fix: recreate widget div
* fix: Stop using global variables and use getDiv()
* Revert "fix: Stop using global variables and use getDiv()"
This reverts commit 322c4d884b.
* fix: reset widget div
This commit is contained in:
@@ -113,7 +113,7 @@ export interface PositionMetrics {
|
||||
* @internal
|
||||
*/
|
||||
export function createDom() {
|
||||
if (div) {
|
||||
if (document.querySelector('.blocklyDropDownDiv')) {
|
||||
return; // Already created.
|
||||
}
|
||||
div = document.createElement('div');
|
||||
|
||||
@@ -184,7 +184,7 @@ function getTargetObject(
|
||||
* Create the tooltip div and inject it onto the page.
|
||||
*/
|
||||
export function createDom() {
|
||||
if (containerDiv) {
|
||||
if (document.querySelector('.blocklyTooltipDiv')) {
|
||||
return; // Already created.
|
||||
}
|
||||
// Create an HTML container for popup overlays (e.g. editor widgets).
|
||||
|
||||
@@ -19,6 +19,9 @@ let owner: unknown = null;
|
||||
/** Optional cleanup function set by whichever object uses the widget. */
|
||||
let dispose: (() => void) | null = null;
|
||||
|
||||
/** A class name representing the current owner's workspace container. */
|
||||
const containerClassName = 'blocklyWidgetDiv';
|
||||
|
||||
/** A class name representing the current owner's workspace renderer. */
|
||||
let rendererClassName = '';
|
||||
|
||||
@@ -45,18 +48,21 @@ export function getDiv(): HTMLDivElement | null {
|
||||
*/
|
||||
export function testOnly_setDiv(newDiv: HTMLDivElement | null) {
|
||||
containerDiv = newDiv;
|
||||
if (newDiv === null) {
|
||||
document.querySelector('.' + containerClassName)?.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the widget div and inject it onto the page.
|
||||
*/
|
||||
export function createDom() {
|
||||
if (containerDiv) {
|
||||
if (document.querySelector('.' + containerClassName)) {
|
||||
return; // Already created.
|
||||
}
|
||||
|
||||
containerDiv = document.createElement('div') as HTMLDivElement;
|
||||
containerDiv.className = 'blocklyWidgetDiv';
|
||||
containerDiv.className = containerClassName;
|
||||
const container = common.getParentContainer() || document.body;
|
||||
container.appendChild(containerDiv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user