Skip to content

Commit

Permalink
fix: fixed #2102
Browse files Browse the repository at this point in the history
  • Loading branch information
arnog committed Nov 17, 2023
1 parent 2f605e2 commit b2280ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- **#2141**: Added St Mary's Road symbols for theoretical computer science,
including `\mapsfrom`.
- **#2158** Support the German keyboard layout on Linux.
- **#2102** The mathfield element now respects the `user-select` CSS property.
If it is set to `none`, the mathfield will not be selectable.

## 0.96.1 (2023-11-15)

Expand Down
9 changes: 7 additions & 2 deletions src/public/mathfield-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,11 @@ export class MathfieldElement extends HTMLElement implements Mathfield {
}

this.attachShadow({ mode: 'open', delegatesFocus: true });

const computedStyle = window.getComputedStyle(this);
const pointerEvents = computedStyle.userSelect === 'none' ? 'none' : 'auto';
const shadowRootMarkup = `<span style="pointer-events:${pointerEvents}"></span><slot style="display:none"></slot>`;

if (this.shadowRoot && 'adoptedStyleSheets' in this.shadowRoot) {
// @ts-ignore
this.shadowRoot!.adoptedStyleSheets = [
Expand All @@ -1196,13 +1201,13 @@ export class MathfieldElement extends HTMLElement implements Mathfield {
getStylesheet('mathfield-element'),
];
// @ts-ignore
this.shadowRoot!.innerHTML = `<span style="pointer-events:auto"></span><slot style="display:none"></slot>`;
this.shadowRoot!.innerHTML = shadowRootMarkup;
} else {
this.shadowRoot!.innerHTML = `<style>${getStylesheetContent(
'core'
)}${getStylesheetContent('mathfield')}${getStylesheetContent(
'mathfield-element'
)}</style><span style="pointer-events:auto"></span><slot style="display:none"></slot>`;
)}</style>${shadowRootMarkup}`;
}

// Record the (optional) configuration options, as a deferred state
Expand Down

0 comments on commit b2280ce

Please sign in to comment.