Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class TreeSelectFactory {
dialogSelectButton,
] = this.#getTreeSelectElements(inputId);

const drilldownComponent = this.#getDrilldown(treeSelectElement);
const drilldownComponent = this.#getDrilldown(dialogElement);

const treeMultiSelect = new TreeSelect(
createTreeSelectNodes(getNodeElements(dialogElement)),
Expand Down Expand Up @@ -157,7 +157,7 @@ export default class TreeSelectFactory {
dialogSelectButton,
] = this.#getTreeSelectElements(inputId);

const drilldownComponent = this.#getDrilldown(treeSelectElement);
const drilldownComponent = this.#getDrilldown(dialogElement);

const treeSelect = new TreeSelect(
createTreeSelectNodes(getNodeElements(dialogElement)),
Expand Down Expand Up @@ -200,11 +200,12 @@ export default class TreeSelectFactory {
#getTreeSelectElements(inputId) {
const dialogOpenButton = this.#document.getElementById(inputId);
const treeSelectElement = dialogOpenButton?.closest(CONSTANTS.TREE_SELECT);
const breadcrumbsElement = treeSelectElement?.querySelector(CONSTANTS.BREADCRUMB);
const breadcrumbTemplate = treeSelectElement?.querySelector('.modal-body > template');
const dialogElement = this.#document.getElementById(`${inputId}_dialog`)
?? treeSelectElement?.querySelector('dialog');
const breadcrumbsElement = dialogElement?.querySelector(CONSTANTS.BREADCRUMB);
const breadcrumbTemplate = dialogElement?.querySelector('.modal-body > template');
const nodeSelectionElement = treeSelectElement?.querySelector(CONSTANTS.TREE_SELECT_SELECTION);
const nodeSelectionTemplate = nodeSelectionElement?.querySelector(':scope > template');
const dialogElement = treeSelectElement?.querySelector('dialog');
const dialogSelectButton = dialogElement?.querySelector(CONSTANTS.TREE_SELECT_BUTTON);

if (breadcrumbsElement === null
Expand All @@ -231,12 +232,12 @@ export default class TreeSelectFactory {
}

/**
* @param {HTMLDivElement} element
* @param {HTMLElement} container dialog or legacy wrapper containing the drilldown
* @returns {Drilldown}
* @throws {Error} if instance can not be found
*/
#getDrilldown(element) {
const drilldownElement = element.querySelector(CONSTANTS.DRILLDOWN);
#getDrilldown(container) {
const drilldownElement = container.querySelector(CONSTANTS.DRILLDOWN);
if (drilldownElement === null || !drilldownElement.hasAttribute('id')) {
throw new Error('Could not find drilldown element.');
}
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/UI/resources/js/Modal/dist/modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/ILIAS/UI/resources/js/Modal/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
******************************************************************** */

import terser from '@rollup/plugin-terser';
import copyright from '../../../../../../scripts/Copyright-Checker/copyright';
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright';
import copyright from '../../../../../../scripts/Copyright-Checker/copyright.js';
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright.js';

export default {
input: './src/index.js',
Expand Down
40 changes: 40 additions & 0 deletions components/ILIAS/UI/resources/js/Modal/src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@ export default class Modal {
*/
constructor(jquery) {
this.#jquery = jquery;
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => this.#moveModalsToBody());
} else {
this.#moveModalsToBody();
}
}

/**
* Reparents every native <dialog> to document.body so headings inside dialogs
* do not sit between main-content headings in document order. Call sites that
* previously used descendant selectors must resolve dialogs by id instead.
*/
#moveModalsToBody() {
document.querySelectorAll('dialog').forEach((dialog) => {
if (dialog.parentElement?.closest('dialog')) {
return;
}
const body = dialog.ownerDocument.body;
if (body && dialog.parentElement !== body) {
body.appendChild(dialog);
}
});
}

/**
* @param {HTMLDialogElement|null|undefined} dialog
*/
#ensureDialogInBody(dialog) {
if (!dialog || dialog.tagName !== 'DIALOG') {
return;
}
const body = dialog.ownerDocument.body;
if (body && dialog.parentElement !== body) {
body.appendChild(dialog);
}
}

/**
Expand Down Expand Up @@ -61,12 +96,17 @@ export default class Modal {
}
this.#triggeredSignalsStorage[signalData.id] = true;

if (component.tagName === 'DIALOG') {
this.#ensureDialogInBody(component);
}

if (options.ajaxRenderUrl) {
this.#jquery(component).load(options.ajaxRenderUrl, () => {
const dialog = component.querySelector('dialog');
if (!dialog) {
throw new Error('url did not return a dialog');
}
this.#ensureDialogInBody(dialog);
dialog.showModal();
il.UI.lightbox.maybeInitCarousel(component);
this.#triggeredSignalsStorage[signalData.id] = false;
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/UI/resources/js/Prompt/dist/prompt.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/ILIAS/UI/resources/js/Prompt/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
******************************************************************** */

import terser from '@rollup/plugin-terser';
import copyright from '../../../../../../scripts/Copyright-Checker/copyright';
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright';
import copyright from '../../../../../../scripts/Copyright-Checker/copyright.js';
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright.js';

export default {
input: './src/prompt.js',
Expand Down
7 changes: 5 additions & 2 deletions components/ILIAS/UI/resources/js/Prompt/src/prompt.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Prompt {
#component;

/**
* @type {HTMLPromptElement}
* @type {HTMLDialogElement}
*/
#prompt;

Expand All @@ -40,7 +40,10 @@ export default class Prompt {
if (this.#component === null) {
throw new Error(`Could not find a Prompt for id '${componentId}'.`);
}
this.#prompt = this.#component.getElementsByTagName('dialog').item(0);
this.#prompt = document.getElementById(`${componentId}_dialog`);
if (this.#prompt === null) {
throw new Error(`Could not find dialog for Prompt '${componentId}'.`);
}
}

/**
Expand Down
Loading
Loading