github / github/remote-input-element

Ability to prevent/cancel fetch on focus

未关闭
#31 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
91
派生
17
平均合并
1 天 19 小时
30 天内合并 PR
5

描述

I'm using the remote input in a [SelectMenu](https://primer.style/css/components/select-menu#githubcom-usage). The menu's SelectMenu-list is controlled by the remote input. When the page is rendered server-side, a few commonly used items are rendered in the SelectMenu-list to save the user time. The problem I have is these items are instantly cleared when the SelectMenu opens and the remote input receives focus due to the remote input doing the initial fetch.

Would the team be open to a PR that makes it possible to skip/cancel the initial fetch? I'd like to avoid the unnecessary round-trip to the server to get suggestions for the empty string query and preserve by server-side rendered default SelectMenu items. If yes, should it be done via html attribute or by preventing default on one of the custom events?

Two other questions:
1. Should load fire before the fetch starts?
https://github.com/github/remote-input-element/blob/4ec740a69773f4b18dfeef28d52434b0475bcd13/src/index.ts#L132-L134
2. Most github elements store state in a weakmap and use module functions (as opposed to class properties and methods). This makes it difficult to monkey patch component behavior. Is that the intent?

Thank you for sharing the github elements. They're super useful and I love the decoupling of the styles from the behavior.

贡献指南

打开贡献指南

调研方向

从 src/index.ts 第 132-134 行附近开始,跟踪由焦点触发的初始 fetch 及其自定义事件。确定 opt-out 或取消 API 应如何与远程输入以及服务器渲染的 SelectMenu-list 项进行交互,然后将完成条件定义为:在不发起空查询请求的情况下保留这些项。该 issue 没有提到测试文件,因此请在更改行为之前找到现有的 fetch 或事件覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
frontend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。