X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/92b4ae921e7393c504d846c6476766aec57da313..ee0307d05caf3eeed3d1acb8398937fadd2c7c25:/src/components/autocomplete/autocomplete.tsx diff --git a/src/components/autocomplete/autocomplete.tsx b/src/components/autocomplete/autocomplete.tsx index 67bc9fa1..17d85e85 100644 --- a/src/components/autocomplete/autocomplete.tsx +++ b/src/components/autocomplete/autocomplete.tsx @@ -2,13 +2,13 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +import React from 'react'; import { Input as MuiInput, Chip as MuiChip, Popper as MuiPopper, Paper as MuiPaper, - FormControl, InputLabel, StyleRulesCallback, withStyles, RootRef, ListItemText, ListItem, List, FormHelperText + FormControl, InputLabel, StyleRulesCallback, withStyles, RootRef, ListItemText, ListItem, List, FormHelperText, Tooltip } from '@material-ui/core'; import { PopperProps } from '@material-ui/core/Popper'; import { WithStyles } from '@material-ui/core/styles'; @@ -30,6 +30,7 @@ export interface AutocompleteProps { onDelete?: (item: Item, index: number) => void; onSelect?: (suggestion: Suggestion) => void; renderChipValue?: (item: Item) => string; + renderChipTooltip?: (item: Item) => string; renderSuggestion?: (suggestion: Suggestion) => React.ReactNode; } @@ -171,11 +172,22 @@ export class Autocomplete extends React.Component - onDelete ? onDelete(item, index) : undefined} /> + (item, index) => { + const tooltip = this.props.renderChipTooltip ? this.props.renderChipTooltip(item) : ''; + if (tooltip && tooltip.length) { + return + + onDelete(item, index)) : undefined} /> + + } else { + return onDelete(item, index)) : undefined} /> + } + } ); }