Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DashboardMiscOptions.trigger requires string, but findAllDOMElements accepts Node as well #5099

Closed
2 tasks done
mbolli opened this issue Apr 19, 2024 · 0 comments · Fixed by #5106
Closed
2 tasks done
Labels

Comments

@mbolli
Copy link

mbolli commented Apr 19, 2024

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

This is less of a bug and more of a correct typing-issue.

The trigger field on DashboardMiscOptions requires string:

But processing calls findAlDOMElements(this.opts.trigger):

const showModalTrigger = findAllDOMElements(this.opts.trigger)

Which allows DOM Elements as well:

function findAllDOMElements(element: unknown): Node[] | null {
if (typeof element === 'string') {
const elements = document.querySelectorAll(element)
return elements.length === 0 ? null : Array.from(elements)
}
if (typeof element === 'object' && isDOMElement(element)) {
return [element]
}
return null
}

Expected behavior

That the trigger field mirrors the accepted types of findAllDOMElements().

Actual behavior

The trigger field requires an optional string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant