fix: add forwardRef support to button components#98
Open
wendyyuchensun wants to merge 2 commits intocoseeing:mainfrom
Open
fix: add forwardRef support to button components#98wendyyuchensun wants to merge 2 commits intocoseeing:mainfrom
wendyyuchensun wants to merge 2 commits intocoseeing:mainfrom
Conversation
wendyyuchensun
commented
Mar 8, 2026
| type="button" | ||
| className={cn( | ||
| 'flex items-center justify-center text-text-primary border border-border-main rounded-lg', | ||
| 'flex items-center justify-center bg-white text-text-primary border border-border-main rounded-lg', |
Collaborator
Author
There was a problem hiding this comment.
bg-white 跟 forwardRef 原題無關,但順便修。
wendyyuchensun
commented
Mar 8, 2026
| type="button" | ||
| className={cn( | ||
| 'flex items-center justify-center text-primary rounded-lg', | ||
| 'flex items-center justify-center bg-white text-primary rounded-lg', |
Collaborator
Author
There was a problem hiding this comment.
bg-white 跟 forwardRef 原題無關,但順便修。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
用
React.forwardRef包裝 PrimaryButton、SecondaryButton 與 TertiaryButton,讓使用者可直接將 ref 綁定至底層的<button>元素。此變更適用於需要存取 DOM 節點的情境,例如將按鈕作為 Headless UI
Menu.Button的觸發元件時,Headless UI 需透過 ref 控制焦點與定位,若元件未支援forwardRef則會導致功能異常(e.g. 若無 forwardRef,當 menu 打開時按 esc 鍵,focus 會跑到 document.body,而非預期的 menu trigger button)。