mirror of
https://github.com/daledesilva/obsidian_project-browser.git
synced 2026-07-22 09:40:27 +00:00
Add pointer event handling to notice components
- Enhanced SCSS for notice components to ensure pointer events are enabled for scroll and footer sections. - Implemented TypeScript function to manage click events, preventing click bubbling to the body and ensuring proper interaction with links and buttons in the notice.
This commit is contained in:
parent
fd3d4274a4
commit
bd90adef3d
2 changed files with 18 additions and 0 deletions
|
|
@ -29,6 +29,7 @@
|
|||
width: 100%;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
pointer-events: auto;
|
||||
|
||||
.ddc_pb_notice-scroll {
|
||||
flex: 1 1 auto;
|
||||
|
|
@ -37,6 +38,7 @@
|
|||
overscroll-behavior: contain;
|
||||
padding: var(--ddc_pb_notice-content-padding);
|
||||
padding-block-end: var(--size-4-2);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.ddc_pb_notice-footer {
|
||||
|
|
@ -46,6 +48,7 @@
|
|||
align-items: center;
|
||||
gap: 1em;
|
||||
padding: var(--ddc_pb_notice-content-padding);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.ddc_pb_notice-footer-links {
|
||||
|
|
|
|||
|
|
@ -25,9 +25,24 @@ export function createNoticeTemplate(noticeNumber?: number, noticeTotal?: number
|
|||
export function launchPersistentNotice(noticeBody: DocumentFragment) {
|
||||
const notice = new Notice(noticeBody, 0);
|
||||
notice.messageEl.classList.add('ddc_pb_notice');
|
||||
wireNoticePointerHandling(notice.messageEl);
|
||||
return notice;
|
||||
}
|
||||
|
||||
/** Scroll/footer need pointer-events; stop click bubbling so Obsidian won't dismiss on body clicks. */
|
||||
function wireNoticePointerHandling(noticeContentEl: HTMLElement) {
|
||||
noticeContentEl.querySelector('.ddc_pb_notice-scroll')?.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
noticeContentEl.querySelector('.ddc_pb_notice-footer')?.addEventListener('click', (event) => {
|
||||
if (event.target instanceof HTMLElement && event.target.closest('a, button')) {
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
function createNoticeLabel(noticeParent: HTMLElement | DocumentFragment, noticeNumber?: number, noticeTotal?: number): HTMLParagraphElement {
|
||||
const labelEl = noticeParent.createEl('p');
|
||||
let labelText = `Project Browser plugin`;
|
||||
|
|
|
|||
Loading…
Reference in a new issue