feat: Add triggerRef and maxHeight to Dropdown#4365
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4365 +/- ##
=======================================
Coverage 97.45% 97.45%
=======================================
Files 902 902
Lines 26469 26474 +5
Branches 9540 9546 +6
=======================================
+ Hits 25795 25800 +5
+ Misses 668 631 -37
- Partials 6 43 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}> | ||
| {trigger} | ||
| </div> | ||
| {!externalTriggerRef && ( |
There was a problem hiding this comment.
What problem does this solve? Do we need the external trigger to be a semantic element so that we cannot have a div wrapper around it, or do we need it because the wrapper affects the layout? If the latter is true, we can instead conditionally apply display: contents to the internal wrapper - which should be a cleaner solution.
There was a problem hiding this comment.
Over-arching problem which is slightly specific to triggers in shortcuts is that it wraps the trigger with a div element which would be semantically incorrect for shortcut triggers as they are rendered inside paragraph elements. Completely excluding the wrapper means the consumer of dropdown has control over the DOM structure. So this is less about layout and more about semantics and it's a more verbose set up than swapping our the div with a span conditionally.
There was a problem hiding this comment.
Take a look at the customTriggerBuilder - an internal prop in the ButtonDropdown. Can we use a similar approach here?
interface TriggerProps {
id: string;
ref: React.Ref<HTMLElement>;
}
<Dropdown
renderTrigger={(triggerProps) => <button className="my-trigger" {...triggerProps} />}
/>
There was a problem hiding this comment.
I don't think this makes sense for triggers in shortcuts. It would be quite complex to handle all of the trigger behaviours though a function like that, we need more control over the actual trigger element that the dropdown anchors to so I'm inclined to sticking with the ref approach, but not pulling the ID from it as your suggestion from the other comment.
There was a problem hiding this comment.
For reference I experimented by adding a function and seeing how we could use it in shortcuts but it's too complex to control the trigger properly. If the trigger were more static than text in an input then it could work
Description
Supplementary to shortcuts in PromptInput:
Related links, issue #, if available: n/a
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.