Skip to content

Commit

Permalink
Added catch for promise (#1858)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Mar 27, 2024
1 parent ac8b71e commit 372442d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/jsapi-components/src/spectrum/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import {
import { useApi } from '@deephaven/jsapi-bootstrap';
import { dh as DhType } from '@deephaven/jsapi-types';
import { Formatter } from '@deephaven/jsapi-utils';
import Log from '@deephaven/log';
import { PICKER_ITEM_HEIGHT, PICKER_TOP_OFFSET } from '@deephaven/utils';
import { useCallback, useEffect, useMemo } from 'react';
import useGetItemIndexByValue from '../../useGetItemIndexByValue';
import { useViewportData } from '../../useViewportData';
import { getPickerKeyColumn } from './PickerUtils';
import { usePickerItemRowDeserializer } from './usePickerItemRowDeserializer';

const log = Log.module('Picker');

export interface PickerProps extends Omit<PickerPropsBase, 'children'> {
table: DhType.Table;
/* The column of values to use as item keys. Defaults to the first column. */
Expand Down Expand Up @@ -81,13 +84,17 @@ export function Picker({
function setViewportFromSelectedKey() {
let isCanceled = false;

getItemIndexByValue().then(index => {
if (index == null || isCanceled) {
return;
}

setViewport(index);
});
getItemIndexByValue()
.then(index => {
if (index == null || isCanceled) {
return;
}

setViewport(index);
})
.catch(err => {
log.error('Error setting viewport from selected key', err);
});

return () => {
isCanceled = true;
Expand Down

0 comments on commit 372442d

Please sign in to comment.