Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

允許停用或隱藏 <option> #50

Closed
graphemecluster opened this issue Nov 22, 2024 · 2 comments
Closed

允許停用或隱藏 <option> #50

graphemecluster opened this issue Nov 22, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@graphemecluster
Copy link
Member

若果把

{options.map((option, i) => {
const { value, text } = option;
return (
<option key={i} value={i}>
{text ?? String(value)}
</option>
);
})}
改成

 {options.flatMap((option, i) => {
   if (option["hidden"]) {
     return [];
   }
   const { value, text } = option;
   return [
     <option key={i} value={i} disabled={!!option["disabled"]}>
       {text ?? String(value)}
     </option>,
   ];
 })}

則有一個問題,以 nk2028/tshet-uinh-examples#60 (comment) 作例,若寫成

  ['調式', [8,
    '調值(趙元任)', '調值(王璞)', '調線(趙元任)', '調線(王璞)',
    { value: '附標', hidden: 選項.注音符號 !== false }, '調號上標', '調號', '調符',
  ]],

則,若用户選擇「附標」後勾選「注音符號」,此時選擇仍為「附標」,但因 <select> 無此 <option> value,介面會顯示成第一個 <option>,即「調值(趙元任)」,但我們未有機制確保選項已加入 { reset: 選項.注音符號 !== false }disabled 亦同。
徵求 @syimyuzya 意見。

@graphemecluster graphemecluster added the enhancement New feature or request label Nov 23, 2024
@syimyuzya
Copy link
Member

這樣的 GUI 動態行為,應該用動態產生 option 列表(及預設值),並用 reset 來實現。

新版的 unt 切韻擬音方案就做了這個效果(比如其「後低元音」選項),可以參考。

@syimyuzya
Copy link
Member

另外,還有另一個改進空間,可以改善它的情況:想辦法讓方案更方便地 watch 某些選項的變動。【由於是 GUI 專屬功能,所以該功能最好不要與主要邏輯過於耦合(因為推導方案不一定僅在推導器上執行,也可能利用 tshet-uinh-deriver-tools 提供的 JS API,以程式呼叫使用)

@ayaka14732 ayaka14732 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants