Compare commits

..

No commits in common. "d880130303fc3e9b5d2f987359aa22da64ce4101" and "dc3c9bc74434126b7a794a54b9ac9b8d6ee2a493" have entirely different histories.

3 changed files with 16 additions and 33 deletions

View file

@ -582,7 +582,7 @@ class NoteForm extends HTMLElement {
this.reminderPicker = this.querySelector("reminder-picker"); this.reminderPicker = this.querySelector("reminder-picker");
this.addEventListener("click", (e) => { this.addEventListener("click", (e) => {
const textareaInside = e.target.querySelectorAll("textarea")[1]; const textareaInside = e.target.querySelector("textarea");
if (textareaInside) { if (textareaInside) {
textareaInside.focus(); textareaInside.focus();
return true; return true;

View file

@ -166,13 +166,13 @@ editNote.addEventListener("updateNoteInProgress", async (e) => {
editNote.addEventListener("updateNote", async (e) => { editNote.addEventListener("updateNote", async (e) => {
await Notes.update(e.detail); await Notes.update(e.detail);
Notes.saveStorage(); Notes.saveStorage();
closeModal(editNoteDialog); editNoteDialog.close();
}); });
editNote.addEventListener("deleteNote", async (e) => { editNote.addEventListener("deleteNote", async (e) => {
await Notes.remove(e.detail); await Notes.remove(e.detail);
Notes.saveStorage(); Notes.saveStorage();
closeModal(editNoteDialog); editNoteDialog.close();
}); });
// The notes rendering routine is optimized to replace only // The notes rendering routine is optimized to replace only
@ -234,22 +234,6 @@ async function render() {
notes.forEach((n) => (currentNotes[n.id] = structuredClone(n))); notes.forEach((n) => (currentNotes[n.id] = structuredClone(n)));
} }
function openModal(modal) {
document.body.style.top = `-${window.scrollY}px`;
document.body.style.position = "fixed";
modal.showModal();
}
function closeModal(modal) {
modal.close();
const scrollY = document.body.style.top;
document.body.style.position = "";
document.body.style.top = "";
window.scrollTo(0, parseInt(scrollY || "0") * -1);
}
function renderNote(note) { function renderNote(note) {
const container = document.createElement("div"); const container = document.createElement("div");
container.id = note.id; container.id = note.id;
@ -303,7 +287,7 @@ function renderNote(note) {
if (e.target.tagName !== "A") { if (e.target.tagName !== "A") {
const note = await Notes.get(container.id); const note = await Notes.get(container.id);
editNote.load(structuredClone(note)); editNote.load(structuredClone(note));
openModal(editNoteDialog); editNoteDialog.showModal();
} }
}); });

View file

@ -50,7 +50,7 @@ dialog {
border: 0; border: 0;
background: transparent; background: transparent;
max-width: 100vw; max-width: 100vw;
max-height: 90vh; max-height: 100vh;
} }
::backdrop { ::backdrop {
@ -61,7 +61,10 @@ dialog {
body { body {
line-height: 1.5; line-height: 1.5;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
width: 100vw; }
body:has(dialog[open]) {
overflow: hidden;
} }
img, img,
@ -176,11 +179,7 @@ task-list li:has(.checkbox input:checked) {
} }
task-list-item .remove { task-list-item .remove {
width: 3em; visibility: hidden;
}
task-list-item .remove button {
display: none;
} }
@media (hover: hover) and (pointer: fine) { @media (hover: hover) and (pointer: fine) {
@ -188,17 +187,17 @@ task-list-item .remove button {
background: var(--highlight-color); background: var(--highlight-color);
} }
task-list li:hover .remove button { task-list li:hover .remove {
display: block; visibility: visible;
} }
} }
task-list-item .remove button:active { task-list-item .remove:has(button:active) {
display: block; visibility: visible;
} }
task-list-item:has(textarea:focus) .remove button { task-list-item:has(textarea:focus) .remove {
display: block; visibility: visible;
} }
task-list-item .checkbox input { task-list-item .checkbox input {