单击时如何将专注于选择?

发布于 2025-02-09 04:24:39 字数 1071 浏览 1 评论 0原文

单击材料时,ui在iframe中每次都会在页面顶部选择滚动。

我在React应用程序上创建了一个月和年的选项。当我单击“选择按钮”时,它会自动滚动到页面顶部,这很烦人 当我仅在IFRAME内加载React应用程序时,就会发生此问题。 没有iframe,它可以正常工作

<Select
         
            variant="outlined"
            IconComponent={KeyboardArrowDown}
            labelId="demo-simple-select-label"
            style={{ marginRight: "10px", fontSize: Theme.typography.caption.fontSize}}
            placeholder={Content?.expiryMonthPlaceHolder}
            id="expirationMonth"
            value={expirationMonth}
            label="MM"
            className={classes.cardmonth}
            //   expirationMonth ? classes.cardmonth : classes.cardmonthEmpty
            // }
            onChange={e => {
              setExpirationMonth(e.target.value);
            }}
          >
            {months.map(month => (
              <MenuItem key={month} value={month}  autoFocus={true} style={{ fontSize: Theme.typography.caption.fontSize }}>
                {month}
              </MenuItem>
            ))}
          </Select>

When clicking on the Material Ui select it scrolls to top of the page every time within iframe.

I have created on react application which has select option for month and year. when i click on the select button it auto scrolls to the top of the page which is very annoying
This issue is occurring when i am loading react app within iframe only.
without iframe it is working fine

<Select
         
            variant="outlined"
            IconComponent={KeyboardArrowDown}
            labelId="demo-simple-select-label"
            style={{ marginRight: "10px", fontSize: Theme.typography.caption.fontSize}}
            placeholder={Content?.expiryMonthPlaceHolder}
            id="expirationMonth"
            value={expirationMonth}
            label="MM"
            className={classes.cardmonth}
            //   expirationMonth ? classes.cardmonth : classes.cardmonthEmpty
            // }
            onChange={e => {
              setExpirationMonth(e.target.value);
            }}
          >
            {months.map(month => (
              <MenuItem key={month} value={month}  autoFocus={true} style={{ fontSize: Theme.typography.caption.fontSize }}>
                {month}
              </MenuItem>
            ))}
          </Select>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文