Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Search): improve accessibility #4522

Merged
merged 1 commit into from Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/search/index.tsx
Expand Up @@ -53,17 +53,17 @@ function Search(
}

function onCancel() {
if (slots.action) {
return;
}

emit(ctx, 'input', '');
emit(ctx, 'cancel');
}

return (
<div class={bem('action')}>
{slots.action ? (
slots.action()
) : (
<div onClick={onCancel}>{props.actionText || t('cancel')}</div>
)}
<div class={bem('action')} role="button" tabindex="0" onClick={onCancel}>
{slots.action ? slots.action() : props.actionText || t('cancel')}
</div>
);
}
Expand Down
6 changes: 2 additions & 4 deletions src/search/test/__snapshots__/demo.spec.js.snap
Expand Up @@ -27,9 +27,7 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
</div>
<div class="van-search__action">
<div>取消</div>
</div>
<div role="button" tabindex="0" class="van-search__action">取消</div>
</div>
</form>
</div>
Expand All @@ -45,7 +43,7 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
</div>
<div class="van-search__action">
<div role="button" tabindex="0" class="van-search__action">
<div>搜索</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/search/test/__snapshots__/index.spec.js.snap
Expand Up @@ -11,9 +11,7 @@ exports[`action-text prop 1`] = `
</div>
</div>
</div>
<div class="van-search__action">
<div>Custom Text</div>
</div>
<div role="button" tabindex="0" class="van-search__action">Custom Text</div>
</div>
`;

Expand Down
2 changes: 1 addition & 1 deletion src/search/test/index.spec.js
Expand Up @@ -35,7 +35,7 @@ test('cancel event', () => {
}
});

const cancel = wrapper.find('.van-search__action div');
const cancel = wrapper.find('.van-search__action');
cancel.trigger('click');

expect(onInput).toHaveBeenCalledWith('');
Expand Down