ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

Modal组件渲染后控制台提示报错信息,"aria-hidden" 被使用到了可聚焦元素上

Open BingHua017 opened this issue 1 year ago • 27 comments
trafficstars

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.2.3

Environment

chrome版本 127.0.6533.73(正式版本)(64 位)

Reproduction link

https://www.antdv.com/components/modal-cn

Steps to reproduce

  1. 使用chrome最新版本;
  2. 打开antdv组件库的modal界面;
  3. 打开console并触发页面的modal组件即可见到此报错信息;

What is expected?

预期是没有此报错信息

What is actually happening?

使用modal组件并调用后console显示如下报错信息: Blocked aria-hidden on a <div> element because the element that just received focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.

MDN文档关于aria-hidden的说明中提到:不要在可以获得焦点的元素上使用 aria-hidden="true"。

BingHua017 avatar Jul 25 '24 02:07 BingHua017

我也遇到了相同的问题,解决了吗?

mfish-qf avatar Jul 28 '24 05:07 mfish-qf

这个问题我观察了下,换个浏览器就不会报错,在出现报错的浏览器下打开ant design vue官网的modal仍会提示报错,应该和浏览器的版本更新相关

lv107w avatar Jul 29 '24 03:07 lv107w

这是一个与可访问性相关的错误提示,说明你在一个

元素上使用了 aria-hidden 属性,而这个元素或其祖先元素刚刚接收了焦点。这会导致屏幕阅读器等辅助技术无法访问到这个元素,这样的做法是不可取的。

aria-hidden 属性通常用于隐藏不需要辅助技术访问的内容。然而,当一个元素被隐藏时,它不应该接收焦点,因为这会让使用辅助技术的用户无法与这个元素进行交互。

为了避免这个问题,你可以考虑使用 inert 属性。inert 属性不仅会隐藏元素,还会防止它接收焦点。

谁能更新?

FlyingTigerReally avatar Jul 30 '24 03:07 FlyingTigerReally

我也碰见了 前段时间还没有,版本 3.2.20。

LiLongFei0 avatar Jul 30 '24 05:07 LiLongFei0

我这里同样遇到了 版本 4.2.1 ,这似乎和最近浏览器跟新的版本有关

haokejie avatar Aug 01 '24 06:08 haokejie

浏览器也更新了 没有 

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2024年8月1日(星期四) 下午2:11 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [vueComponent/ant-design-vue] Modal组件渲染后控制台提示报错信息,"aria-hidden" 被使用到了可聚焦元素上 (Issue #7749)

我这里同样遇到了 版本 4.2.1 ,这似乎和最近浏览器跟新的版本有关

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

LiLongFei0 avatar Aug 01 '24 06:08 LiLongFei0

同样的问题🤔

SAKURA-CAT avatar Aug 01 '24 08:08 SAKURA-CAT

临时处理的话就先在全局把Modal中该属性的元素隐藏 .ant-modal div[aria-hidden="true"] { display: none !important; }

anyc100 avatar Aug 01 '24 09:08 anyc100

官方啥时候把那行代码改一下呀。我浏览器没更新都没报,今天更新了就直接报了这个错。

dcileiu avatar Aug 02 '24 08:08 dcileiu

临时处理的话就先在全局把Modal中该属性的元素隐藏 .ant-modal div[aria-hidden="true"] { display: none !important; }

大概看了一下,这个元素好像没啥用。不知道有没有我没发现的用处。 不管了先隐藏掉再说

dcileiu avatar Aug 02 '24 08:08 dcileiu

临时处理的话就先在全局把Modal中该属性的元素隐藏 .ant-modal div[aria-hidden="true"] { display: none !important; }

没用哎,控制台还是报错的

piggycute avatar Aug 02 '24 10:08 piggycute

临时处理的话就先在全局把Modal中该属性的元素隐藏 .ant-modal div[aria-hidden="true"] { display: none !important; }

没用哎,控制台还是报错的

检查一下样式是否生效

anyc100 avatar Aug 05 '24 02:08 anyc100

临时处理的话就先在全局把Modal中该属性的元素隐藏 .ant-modal div[aria-hidden="true"] { display: none !important; }

没用哎,控制台还是报错的

加在全局css试试,有用的

378406712 avatar Aug 06 '24 08:08 378406712

是不是修复了,我刚刚看控制台不报错了

atdun avatar Aug 06 '24 09:08 atdun

是不是修复了,我刚刚看控制台不报错了

如果修复了这个issue会关闭的。现在官方文档那还能复现这个问题。

dcileiu avatar Aug 06 '24 09:08 dcileiu

是不是修复了,我刚刚看控制台不报错了

如果修复了这个issue会关闭的。现在官方文档那还能复现这个问题。

我现在用的版本是3.2.16前几天确实有这个问题,今天看已经没有了,不知道是怎么回事。

atdun avatar Aug 06 '24 10:08 atdun

现在依然存在这个问题,不过第二次或者刷新之后点击,错误会消失

QCDT avatar Aug 07 '24 09:08 QCDT

现在还有这个问题 版本 127.0.6533.100(正式版本) (64 位)

ajiua avatar Aug 07 '24 10:08 ajiua

现在有解决方法吗 image

szh18 avatar Aug 08 '24 01:08 szh18

+1 image

285858315 avatar Aug 09 '24 02:08 285858315

这个问题我观察了下,换个浏览器就不会报错,在出现报错的浏览器下打开ant design vue官网的modal仍会提示报错,应该和浏览器的版本更新相关

chrome 127版本后就会

yang-xianzhu avatar Aug 09 '24 07:08 yang-xianzhu

现在有解决方法吗 image

你就直接全局加上面那位兄弟的方案,临时解决 div[aria-hidden="true"] { display: none !important; }

dcileiu avatar Aug 09 '24 07:08 dcileiu

是啊 怎么没有修复 或者有什么更好的解决方案吗

weijuer avatar Aug 12 '24 03:08 weijuer

这个问题好像也导致了我的select组件无法open?

gezichenshan avatar Aug 12 '24 05:08 gezichenshan

Ant Design官方已修复 50170

Jzow avatar Aug 13 '24 15:08 Jzow

.ant-modal div[aria-hidden="true"] { display: none !important; } 临时方案中的display: none !important;
发现一个bug,弹窗内容中如果有a-tab组件切换时候内容显示不出来,改成visibility: hidden !important;后正常

jfyear1994 avatar Aug 15 '24 02:08 jfyear1994

我ant-design-vue是4.2.3版本,Modal弹窗也报这个错误,谷歌最新的版本

pzm666 avatar Aug 27 '24 01:08 pzm666

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Oct 26 '24 02:10 github-actions[bot]

这个问题我最近也遇到了,是在a-modal组件使用的时候出现的,但是在我排查后发现是组件内的表单项配置出了问题,修复表单项配置(可能是字段名,赋值逻辑有问题)后就没出现这个报错了。仅供给各位参考。

wilding96 avatar Dec 02 '24 02:12 wilding96