Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bf2410b
disable item in datalist
VolodymyrKovalM Jan 28, 2019
2e9e2e0
added story
VolodymyrKovalM Jan 28, 2019
4eb7bfb
Merge branch 'master' of github.com:Talend/ui into vkoval/feat/TMC-15…
VolodymyrKovalM Jan 28, 2019
f4acaef
remove unused variable
VolodymyrKovalM Jan 28, 2019
012b409
Merge branch 'master' into vkoval/feat/TMC-15843/disabled-item-in-dat…
VolodymyrKovalM Jan 28, 2019
2b463e0
Merge branch 'master' into vkoval/feat/TMC-15843/disabled-item-in-dat…
jsomsanith-tlnd Jan 29, 2019
f3dd483
Merge branch 'master' of github.com:Talend/ui into vkoval/feat/TMC-15…
VolodymyrKovalM Jan 29, 2019
755ebf3
pass aria-disabled prop
VolodymyrKovalM Jan 29, 2019
39a933d
Merge branch 'master' of github.com:Talend/ui into vkoval/feat/TMC-15…
VolodymyrKovalM Jan 29, 2019
8360695
Merge branch 'vkoval/feat/TMC-15843/disabled-item-in-datalist' of git…
VolodymyrKovalM Jan 29, 2019
645715b
fix bug with initial index selecting
VolodymyrKovalM Jan 29, 2019
0fc3fbf
Merge branch 'master' of github.com:Talend/ui into vkoval/feat/TMC-15…
VolodymyrKovalM Jan 29, 2019
f780d25
Merge branch 'master' into vkoval/feat/TMC-15843/disabled-item-in-dat…
jsomsanith-tlnd Jan 30, 2019
1835c97
revert lines
VolodymyrKovalM Jan 30, 2019
d5648cb
Merge branch 'master' of github.com:Talend/ui into vkoval/feat/TMC-15…
VolodymyrKovalM Jan 30, 2019
7c9516b
Merge branch 'vkoval/feat/TMC-15843/disabled-item-in-datalist' of git…
VolodymyrKovalM Jan 30, 2019
e832f27
Merge branch 'master' into vkoval/feat/TMC-15843/disabled-item-in-dat…
Jan 30, 2019
fedac51
Merge branch 'master' into vkoval/feat/TMC-15843/disabled-item-in-dat…
VolodymyrKovalM Jan 31, 2019
8901735
Merge branch 'master' into vkoval/feat/TMC-15843/disabled-item-in-dat…
VolodymyrKovalM Feb 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/components/src/Datalist/Datalist.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ class Datalist extends Component {
if (this.props.multiSection) {
newValue = this.state.suggestions[sectionIndex].suggestions[itemIndex];
}
if (newValue.disabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to follow that PR I guess moroshko/react-autowhatever#35

Copy link
Contributor Author

@VolodymyrKovalM VolodymyrKovalM Jan 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, also saw that PR, but it was done more than a year ago (
And as there is no any activity on that PR, there is not guarantee that we will get such functionality til release
But we can follow of course

event.preventDefault();
return;
}
this.updateValue(event, newValue, true);
}

Expand Down Expand Up @@ -233,7 +237,7 @@ class Datalist extends Component {
} else {
const index = this.props.titleMap.findIndex(item => item.name === value);
this.setState({
focusedItemIndex: index,
focusedItemIndex: index === -1 ? null : index,
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/Typeahead/Typeahead.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ function Typeahead({ onToggle, icon, position, docked, ...rest }) {
...themeProps,
...inputProps,
items: rest.items || [],
itemProps: {
itemProps: ({ itemIndex }) => ({
onMouseDown: rest.onSelect,
'data-feature': rest['data-feature'],
},
'aria-disabled': rest.items[itemIndex] && rest.items[itemIndex].disabled,
}),
};

return <Autowhatever {...autowhateverProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ export function renderItem(item, { value }) {
title = (item.title || item.name || '').trim();
description = item.description;
}

return (
<div className={theme.item} title={title}>
<div className={classNames(theme.item, { [theme.disabled]: item.disabled })} title={title}>
Copy link
Contributor

@frassinier frassinier Jan 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typeahead has its own wrapper to display each item (which has the onClick handler) so you can pass disabled if it's a button or an anchor and aria-disabled props.

You can take a look at #1993 for an example

Copy link
Contributor Author

@VolodymyrKovalM VolodymyrKovalM Jan 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks
if it was button, then yes, but the wrapper is < li > element, so disabled on it won't do anything
we will need to pass a class to it

<span className={classNames(theme['item-title'], 'tc-typeahead-item-title')}>
<Emphasis value={value} text={title} />
</span>
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/Typeahead/Typeahead.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ $tc-typeahead-items-font-size: 1.5rem !default;
&-highlighted {
background-color: $tc-typeahead-focused-item-background-color;
}

&.disabled {
color: $silver-chalice;
cursor: not-allowed;

&:hover {
background: none;
}
}
}

.highlight-match {
Expand Down
20 changes: 15 additions & 5 deletions packages/components/stories/Datalist.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const propsMultiSection = {
{
title: 'cat 1',
suggestions: [
{ name: 'foo', value: 'foo', description: 'foo description' },
{ name: 'faa', value: 'faa' },
{ name: 'My foo', value: 'foo', description: 'foo description' },
{ name: 'My faa', value: 'faa' },
],
},
{ title: 'cat 2', suggestions: [{ name: 'bar', value: 'bar' }] },
{ title: 'cat 2', suggestions: [{ name: 'My bar', value: 'bar' }] },
{
title: 'cat 3',
suggestions: [{ name: 'foobar', value: 'foobar', description: 'foobar description' }],
suggestions: [{ name: 'My foobar', value: 'foobar', description: 'foobar description' }],
},
{ title: 'cat 4', suggestions: [{ name: 'lol', value: 'lol' }] },
{ title: 'cat 4', suggestions: [{ name: 'My lol', value: 'lol' }] },
],
onFinish: action('onFinish'),
onChange: action('onChange'),
Expand All @@ -45,6 +45,13 @@ const singleSectionProps = {
onLiveChange: action('onLiveChange'),
};

const titleMapWithDisabledItems = [
{ name: 'My foo', value: 'foo', description: 'foo description', disabled: true },
{ name: 'My bar', value: 'bar' },
{ name: 'My lol', value: 'lol', disabled: true },
{ name: 'My foobar', value: 'foobar', description: 'foobar description' },
];

storiesOf('Datalist', module)
.addDecorator(story => <div className="col-lg-offset-2 col-lg-8">{story()}</div>)
.add('default multiSection', () => {
Expand All @@ -67,6 +74,7 @@ storiesOf('Datalist', module)
.add('default single section', () => {
const restrictedValues = { ...singleSectionProps, restricted: true };
const defaultValue = { ...singleSectionProps, value: 'lol' };
const disabledItems = { ...singleSectionProps, titleMap: titleMapWithDisabledItems };
return (
<form className="form">
<IconsProvider />
Expand All @@ -80,6 +88,8 @@ storiesOf('Datalist', module)
<Datalist {...singleSectionProps} titleMap={[]} isLoading />
<h3>Auto focused :</h3>
<Datalist {...singleSectionProps} autoFocus />
<h3>With disabled Items :</h3>
<Datalist {...disabledItems} autoFocus />
<h3>Insert custom elements via render props :</h3>
<Datalist {...singleSectionProps}>
{(content, { isShown }) => (
Expand Down