@syscore/ui-library 2.0.0-beta-publish-workflow-beta.21 → 2.0.0-beta-publish-workflow-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,6 +111,7 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
111
111
  const inputId = id ?? listId;
112
112
  const rootRef = React.useRef<HTMLDivElement>(null);
113
113
  const inputRef = React.useRef<HTMLInputElement>(null);
114
+ const listRef = React.useRef<HTMLUListElement>(null);
114
115
 
115
116
  const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
116
117
  const [uncontrolledValue, setUncontrolledValue] = React.useState(
@@ -163,6 +164,17 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
163
164
  setHighlighted(query ? 0 : -1);
164
165
  }, [query, isOpen]);
165
166
 
167
+ // Arrow-key nav moves `highlighted` but renders nothing new — for a long
168
+ // list (e.g. ~150 countries/languages) the highlighted row can end up
169
+ // scrolled out of view with nothing visibly tracking the keyboard focus.
170
+ React.useEffect(() => {
171
+ if (!isOpen || highlighted < 0) return;
172
+ const item = listRef.current?.children[highlighted] as
173
+ | HTMLElement
174
+ | undefined;
175
+ item?.scrollIntoView({ block: "nearest" });
176
+ }, [highlighted, isOpen]);
177
+
166
178
  React.useEffect(() => {
167
179
  const onPointerDown = (event: PointerEvent) => {
168
180
  if (!rootRef.current?.contains(event.target as Node)) {
@@ -382,6 +394,7 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
382
394
 
383
395
  {isOpen && !error ? (
384
396
  <ul
397
+ ref={listRef}
385
398
  id={listId}
386
399
  role="listbox"
387
400
  className={cn("dropdown-menu", isRich && "dropdown-menu--rich")}
package/client/global.css CHANGED
@@ -6126,6 +6126,11 @@ body {
6126
6126
  position: relative;
6127
6127
  z-index: 50;
6128
6128
  max-height: 24rem;
6129
+ /* Radix (position="popper") exposes the trigger's measured width as this
6130
+ var but never applies it itself — without binding to it, the popup
6131
+ shrinks to its longest option's natural width instead of matching the
6132
+ field above it (reported: dropdown narrower than its own input). */
6133
+ width: var(--radix-select-trigger-width);
6129
6134
  min-width: 8rem;
6130
6135
  overflow: hidden;
6131
6136
  border: 1px solid var(--color-cyan-300, #39c9ea);
@@ -6175,8 +6180,24 @@ body {
6175
6180
  scrollbar-color: var(--color-gray-400, #9397a1) transparent;
6176
6181
  }
6177
6182
 
6178
- .select-viewport::-webkit-scrollbar {
6183
+ /* Radix's own SelectViewport renders a <style> tag of its own on every open
6184
+ ([data-radix-select-viewport]{scrollbar-width:none} +
6185
+ [data-radix-select-viewport]::-webkit-scrollbar{display:none}) to hide its
6186
+ default scrollbar. That selector has the exact same specificity as the
6187
+ plain `.select-viewport` rules above, so it was winning the cascade tie
6188
+ and silently cancelling the "visible scrollbar" fix — the CSS above has
6189
+ never actually rendered a scrollbar. Re-declaring against the same
6190
+ [data-radix-select-viewport] attribute Radix sets gives these a strictly
6191
+ higher specificity than Radix's injected rule, so ours wins instead. */
6192
+ .select-viewport[data-radix-select-viewport] {
6193
+ scrollbar-width: thin;
6194
+ scrollbar-color: var(--color-gray-400, #9397a1) transparent;
6195
+ }
6196
+
6197
+ .select-viewport::-webkit-scrollbar,
6198
+ .select-viewport[data-radix-select-viewport]::-webkit-scrollbar {
6179
6199
  width: 8px;
6200
+ display: block;
6180
6201
  }
6181
6202
 
6182
6203
  .select-viewport::-webkit-scrollbar-track {
@@ -65,6 +65,7 @@ const Dropdown = React.forwardRef(
65
65
  const inputId = id ?? listId;
66
66
  const rootRef = React.useRef(null);
67
67
  const inputRef = React.useRef(null);
68
+ const listRef = React.useRef(null);
68
69
  const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
69
70
  const [uncontrolledValue, setUncontrolledValue] = React.useState(
70
71
  defaultValue ?? ""
@@ -108,6 +109,12 @@ const Dropdown = React.forwardRef(
108
109
  React.useEffect(() => {
109
110
  setHighlighted(query ? 0 : -1);
110
111
  }, [query, isOpen]);
112
+ React.useEffect(() => {
113
+ var _a;
114
+ if (!isOpen || highlighted < 0) return;
115
+ const item = (_a = listRef.current) == null ? void 0 : _a.children[highlighted];
116
+ item == null ? void 0 : item.scrollIntoView({ block: "nearest" });
117
+ }, [highlighted, isOpen]);
111
118
  React.useEffect(() => {
112
119
  const onPointerDown = (event) => {
113
120
  var _a;
@@ -294,6 +301,7 @@ const Dropdown = React.forwardRef(
294
301
  isOpen && !error ? /* @__PURE__ */ jsx(
295
302
  "ul",
296
303
  {
304
+ ref: listRef,
297
305
  id: listId,
298
306
  role: "listbox",
299
307
  className: cn("dropdown-menu", isRich && "dropdown-menu--rich"),