transloadit / uppy

The next open source file uploader for web browsers :dog:

Home Page:https://uppy.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mbolli opened this issue · comments

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.