Skip to content

Commit

Permalink
fix: mouse handling
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jan 22, 2021
1 parent 337c340 commit 4238396
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/textchecker-element/src/attach-to-text-area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ export const attachToTextArea = ({
fixable: Boolean(message.fix)
};
const abortSignalMap = new WeakMap<TextCheckerElementRectItem, AbortController>();
let isMouseEnter = false;
return {
id: `${message.ruleId}::${message.line}:${message.column}`,
start: message.index,
end: message.index + 1,
onMouseEnter: ({ rectItem }: { rectItem: TextCheckerElementRectItem }) => {
isMouseEnter = true;
const controller = abortSignalMap.get(rectItem);
debug("enter", controller);
if (controller) {
Expand Down Expand Up @@ -176,12 +178,13 @@ export const attachToTextArea = ({
},
async onMouseLeave({ rectItem }: { rectItem: TextCheckerElementRectItem }) {
try {
isMouseEnter = false;
const controller = abortSignalMap.get(rectItem);
debug("leave", controller);
await delay(500, {
signal: controller?.signal
});
if (textCheckerPopup.isHovering) {
if (textCheckerPopup.isHovering || isMouseEnter) {
return;
}
textCheckerPopup.dismissCard(card);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,7 @@ export class TextCheckerPopupElement extends HTMLElement {
<p class="popup-listItem-content">${item.icon}${item.label}</p>
</li>`;
} else {
return html` <li
@click=${clickHandler}
class="popup-listItem"
style="--padding: ${itemPadding}px; padding-bottom: 0;"
>
return html` <li class="popup-listItem" style="--padding: ${itemPadding}px; padding-bottom: 0;">
<p class="popup-listItem-message">${item.message}</p>
<p class="popup-listItem-content">${item.icon}${item.label}</p>
</li>`;
Expand Down

0 comments on commit 4238396

Please sign in to comment.