简体   繁体   English

带有 native=true 的 Mui Select 不会触发 onOpen 事件

[英]Mui Select with native=true doesn't fire onOpen event

I'm trying to use onOpen with MUI's Select component but it won't fire with native=true.我正在尝试将 onOpen 与 MUI 的 Select 组件一起使用,但它不会在 native=true 时触发。 I need to have this event fire with native select and in the documentation it isn't mentioned that native disables onOpen function. Anyone know why or how to get it to work?我需要用本机 select 触发此事件,并且在文档中没有提到本机禁用 onOpen function。有人知道为什么或如何让它工作吗?

I've tried to find some answers online but none that really gave any answers.我试图在网上找到一些答案,但没有一个真正给出任何答案。

heres a codesandbox where you'll see I tried to console onOpen: https://codesandbox.io/s/withered-night-fyz3eg?file=/demo.js这是一个代码框,您会在其中看到我尝试在打开时进行控制台: https://codesandbox.io/s/withered-night-fyz3eg?file=/demo.js

It works only if native = false https://github.com/mui/material-ui/blob/b5d1b54562372268b6ec7e1b70fb2192442c08ba/packages/mui-material/src/Select/Select.js#L98它仅在native = false https://github.com/mui/material-ui/blob/b5d1b54562372268b6ec7e1b70fb2192442c08ba/packages/mui-material/src/Select/Select.js#L98 时有效


* Callback fired when the component requests to be opened. * 当组件请求打开时触发的回调。
* Use it in either controlled (see the open prop), or uncontrolled mode (to detect when the Select expands). * 在受控(参见open属性)或不受控模式(检测 Select 何时展开)中使用它。 * *
* @param {object} event The event source of the callback. * @param {object} event 回调的事件源。
* onOpen : PropTypes.func * onOpen :PropTypes.func

* If true , the component is shown. * 如果为true ,则显示该组件。
* You can only use it when the native prop is false (default). * 你只能在native prop 为false (默认)时使用它。
* open : PropTypes.bool, *打开:PropTypes.bool,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM