当前位置: 首页 > news >正文

fluent UI v9版本Dialog右上角x按钮聚焦问题解决

右上角x按钮聚焦效果展示
在这里插入图片描述
第一次点击不会聚焦,第二次或多次点击会出现这种情况。如果多个地方公用一个页面里,这个页面包含这个组件,那其它页面刚打开弹框就是聚焦状态,是个样式的问题。
解决:

import * as React from 'react';
import { Button } from '@fluentui/react-components';
import { Dialog, DialogSurface, DialogContent, DialogTrigger } from '@fluentui/react-dialog';
import { Dismiss24Regular } from '@fluentui/react-icons';const DialogExample = () => {const [open, setOpen] = React.useState(false);const buttonRef= React.useRef<HTMLButtonElement>(null);React.useEffect(() => {if (!open && buttonRef.current) {buttonRef.current.blur();}}, [open]);return (
<div>
<Dialog open={open} onOpenChange={(event, data) => setOpen(data.open)}>
<DialogTrigger>
<Button>Open Dialog</Button>
</DialogTrigger>
<DialogSurface>
<DialogBody><DialogTitleaction={<DialogTrigger action="close"><Buttonref={buttonRef}appearance="subtle"aria-label="close"icon={<Dismiss24Regular />}/></DialogTrigger>}>Dialog title</DialogTitle><DialogContent><input placeholder="Input something" /></DialogContent></DialogBody>
</DialogSurface>
</Dialog>
</div>);
};export default DialogExample;

失焦就好了,给close button设置style样式是无效的
在这里插入图片描述

http://www.lryc.cn/news/358655.html

相关文章:

  • 【SAP HANA 33】前端参数多选情况下HANA如何使用IN来匹配?
  • Go 语言中常量和变量的定义、使用
  • 活动预告|6月13日Apache Flink Meetup·香港站
  • 算法(七)插入排序
  • 抖音太可怕了,我卸载了
  • AI大模型在测试中的深度应用与实践案例
  • OOP一元多项式类(运算符重载)
  • Docker compose 的方式一键部署夜莺
  • 解锁私域流量的奥秘:构建独特的私域生态
  • 在CentOS系统上安装Oracle JDK(华为镜像)
  • 7 步解决Android Studio模拟器切换中文输入
  • 如何搭建B2B2C商城系统?开发语言、功能扩展、优势分析
  • Rust的高效易用日志库—tklog
  • LabVIEW调用外部DLL(动态链接库)
  • Python图形界面(GUI)Tkinter笔记(十六):Radiobutton选项功能按钮(单选按钮)
  • 静态路由原理与配置
  • Android 开机动画的启动过程BootAnimation(基于Android10.0.0-r41)
  • Redis 中的 Zset 数据结构详解
  • Python网页处理与爬虫实战:使用Requests库进行网页数据抓取
  • HOW - vscode 使用指南
  • 刚刚!《国家科学技术奖励条例》迎来最新修订
  • MySQL -- SQL笔试题相关
  • VB6 MQTT为什么在物联网应用中使用 MQTT 而不是 HTTP?
  • 软设之希尔排序
  • WPF Binding对象
  • Educational Codeforces Round 127 D. Insert a Progression
  • 树莓集团:构筑全国数字影像生态链
  • 物联网——TIM定时器、PWM驱动呼吸灯、舵机和直流电机
  • Elasticsearch 认证模拟题 -2
  • Java-----Comparable接口和Comparator接口