Skip to content

Commit 706cf2d

Browse files
committed
fix: renderProps ref
1 parent 6ab45c2 commit 706cf2d

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

packages/vkui/src/components/ChipsInputBase/ChipsInputBase.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ export const ChipsInputBase = <O extends ChipOption>({
354354
<React.Fragment key={`${typeof option.value}-${option.value}`}>
355355
{renderChip(
356356
{
357+
/**
358+
* Компилятор сходит с ума из-за рефа внутри handleChipRemove.
359+
* Обходной путь прокидывать ref в свойства для рендер пропов.
360+
*/
361+
...(false
362+
? { '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED': inputRef }
363+
: {}),
357364
'Component': 'div',
358365
'value': option.value,
359366
'label': option.label,

packages/vkui/src/components/ChipsSelect/ChipsSelect.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ export const ChipsSelect = <Option extends ChipOption>({
329329
}
330330
};
331331

332-
const chipsSelectOptions = React.useRef<HTMLElement[]>([]).current;
332+
const chipsSelectOptions = React.useRef<HTMLElement[]>([]);
333333

334334
const scrollToElement = (index: number, center = false) => {
335335
const dropdown = dropdownScrollBoxRef.current;
336-
const item = chipsSelectOptions[index];
336+
const item = chipsSelectOptions.current[index];
337337

338338
/* istanbul ignore if: невозможный кейс (в SSR вызова этой функции не будет) */
339339
if (!item || !dropdown) {
@@ -509,6 +509,13 @@ export const ChipsSelect = <Option extends ChipOption>({
509509
<React.Fragment key={`${typeof option.value}-${option.value}`}>
510510
{renderOption(
511511
{
512+
/**
513+
* Компилятор сходит с ума из-за рефа внутри getRootRef.
514+
* Обходной путь прокидывать ref в свойства для рендер пропов.
515+
*/
516+
...(false
517+
? { '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED': chipsSelectOptions }
518+
: {}),
512519
id: dropdownItemId,
513520
disabled: option.disabled,
514521
hovered: focusedOption
@@ -521,7 +528,7 @@ export const ChipsSelect = <Option extends ChipOption>({
521528
),
522529
getRootRef(node) {
523530
if (node) {
524-
chipsSelectOptions[index] = node;
531+
chipsSelectOptions.current[index] = node;
525532
}
526533
},
527534
onMouseDown(event: React.MouseEvent<HTMLDivElement>) {

packages/vkui/src/components/CustomSelect/CustomSelect.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,15 @@ export function CustomSelect<OptionInterfaceT extends CustomSelectOptionInterfac
576576
return (
577577
<React.Fragment key={`${typeof option.value}-${option.value}`}>
578578
{renderOptionProp({
579+
/**
580+
* Компилятор сходит с ума из-за рефа внутри focusOptionOnMouseMove.
581+
* Обходной путь прокидывать ref в свойства для рендер пропов.
582+
*/
583+
...(false
584+
? {
585+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: lastMousePositionRef,
586+
}
587+
: {}),
579588
option,
580589
hovered,
581590
children: option.label,

0 commit comments

Comments
 (0)