Skip to content

Commit

Permalink
fix: removed double entry by correcting <ul> hierarchy (#176)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #175
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/refined-saved-replies/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/refined-saved-replies/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Previously, the `<div>` and `<ul>` were being added as children of the
existing `<ul>`. They should be added as siblings.
  • Loading branch information
JoshuaKGoldberg authored Nov 16, 2023
1 parent 3f57a61 commit 32e4165
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/content-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ async function main() {
const onOpenSavedRepliesButtonClick = async () => {
// 6. Add the new replies to the saved reply dropdown
const replyCategoriesDetailsMenus = await getSoon(() =>
document.querySelectorAll(`.Overlay-body .js-saved-reply-menu`),
Array.from(
document.querySelectorAll(`.Overlay-body .js-saved-reply-menu`),
)
.map((element) => element.parentNode)
.filter((x): x is ParentNode => !!x),
);

for (const replyCategoriesDetailsMenu of replyCategoriesDetailsMenus) {
Expand Down Expand Up @@ -151,10 +155,13 @@ async function main() {
children: [
createElement("li", {
children: [button],
className: "ActionListItem",
"data-targets": "action-list.items",
role: "none",
}),
],
className: "js-saved-reply-menu ActionListWrap",
"data-view-component": true,
role: "list",
}),
);
Expand Down
2 changes: 1 addition & 1 deletion src/getSoon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export async function getSoon<Value extends Node | NodeList | null>(
export async function getSoon<Value extends Node | Node[] | NodeList | null>(
getter: () => Value,
) {
for (let i = 0; i < 100; i += 1) {
Expand Down

0 comments on commit 32e4165

Please sign in to comment.