Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/soft-pots-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openproject/primer-view-components': patch
---

Fix DangerDialog body scroll behaviour when containing a form: the dialog's confirm and cancel buttons should now always be visible in the viewport, never scrolling with the other dialog content.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ const SUBMIT_BUTTON_SELECTOR = 'input[type=submit],button[type=submit],button[da
class DangerDialogFormHelperElement extends HTMLElement {
@target checkbox: HTMLInputElement | undefined

get form() {
return this.querySelector('form')
}

get submitButton() {
return this.querySelector<HTMLInputElement | HTMLButtonElement>(SUBMIT_BUTTON_SELECTOR)!
}

connectedCallback() {
// makes the custom element behave as if it doesn't exist in the DOM structure, passing all
// styles directly to its children.
this.style.display = 'contents'
if (this.form) {
this.form.style.display = 'contents'
}
Comment on lines +21 to +23
Copy link
Collaborator Author

@myabc myabc Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that this could be considered an anti-pattern. However I'm not sure if the note in the Catalyst docs refers to children that might be appended dynamically at a later point or those present in the DOM at the time connectedCallback() is invoked.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that feels like a smell. I am not a fan of setting styles via JS anyway. Couldn't we set a class on the form and solve it in CSS?

Copy link
Collaborator Author

@myabc myabc Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of setting styles via JS anyway.

I generally agree - at least with regards to visual styling. Although when the style is more "behavioural", I think it can be ok to apply the styles directly - e.g. <scrollable-region> web component.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. Fine for me then 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think of it, we might run into problems because of what you quoted above.. We could avoid that by applying a class directly in the component. So we don't have to rely on the timing to be correct..

this.#reset()
}

Expand Down
Loading