fix: prevent unwarranted a11y warnings on custom Button subclasses (#3238)

* fix: prevent unwarranted a11y warnings on UploadImageButton

* chore: format

* refactor

* fix: remove attr
This commit is contained in:
David Wheatley 2021-12-29 10:37:58 +01:00 committed by GitHub
parent 3290eba64e
commit 32090c64bd

View File

@ -107,7 +107,7 @@ export default class Button<CustomAttrs extends IButtonAttrs = IButtonAttrs> ext
const { 'aria-label': ariaLabel } = this.attrs;
if (!ariaLabel && !extractText(vnode.children) && !this.element?.getAttribute?.('aria-label')) {
if (this.view === Button.prototype.view && !ariaLabel && !extractText(vnode.children) && !this.element?.getAttribute?.('aria-label')) {
fireDebugWarning(
'[Flarum Accessibility Warning] Button has no content and no accessible label. This means that screen-readers will not be able to interpret its meaning and just read "Button". Consider providing accessible text via the `aria-label` attribute. https://web.dev/button-name',
this.element