-
Notifications
You must be signed in to change notification settings - Fork 312
feat(autocomplete): [autocomplete] update autocomplete demos #2384
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,14 @@ import { test, expect } from '@playwright/test' | |||||
test('size', async ({ page }) => { | ||||||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||||||
await page.goto('autocomplete#size') | ||||||
await page.getByRole('textbox', { name: '请输入内容', exact: true }).click() | ||||||
await page.getByRole('option', { name: 'WWWW科技YX公司' }).click() | ||||||
await expect(page.locator('//div[@class="tiny-input tiny-input-medium"]')).toHaveClass(/tiny-input-medium/) | ||||||
const demo = page.locator('#size') | ||||||
const meiumSize = demo.locator('.tiny-autocomplete').first() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in variable name: "meiumSize" should be "mediumSize". The variable name contains a spelling error. - const meiumSize = demo.locator('.tiny-autocomplete').first()
+ const mediumSize = demo.locator('.tiny-autocomplete').first() 📝 Committable suggestion
Suggested change
|
||||||
const defaultSize = demo.locator('.tiny-autocomplete').nth(1) | ||||||
const smallSize = demo.locator('.tiny-autocomplete').nth(2) | ||||||
const miniSize = demo.locator('.tiny-autocomplete').nth(3) | ||||||
Comment on lines
+7
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use more robust selectors instead of order-dependent ones. The current selectors rely on element order which can be fragile if the DOM structure changes. Consider using more specific selectors based on data attributes or size classes. - const meiumSize = demo.locator('.tiny-autocomplete').first()
- const defaultSize = demo.locator('.tiny-autocomplete').nth(1)
- const smallSize = demo.locator('.tiny-autocomplete').nth(2)
- const miniSize = demo.locator('.tiny-autocomplete').nth(3)
+ const mediumSize = demo.locator('[data-size="medium"]')
+ const defaultSize = demo.locator('[data-size="default"]')
+ const smallSize = demo.locator('[data-size="small"]')
+ const miniSize = demo.locator('[data-size="mini"]')
|
||||||
|
||||||
await expect(meiumSize).toHaveCSS('height', '40px') | ||||||
await expect(defaultSize).toHaveCSS('height', '32px') | ||||||
await expect(smallSize).toHaveCSS('height', '28px') | ||||||
await expect(miniSize).toHaveCSS('height', '24px') | ||||||
}) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,11 +1,36 @@ | ||||||
<template> | ||||||
<div class="demo-autocomplete"> | ||||||
<tiny-autocomplete | ||||||
size="medium" | ||||||
v-model="value" | ||||||
:fetch-suggestions="querySearch" | ||||||
placeholder="请输入内容" | ||||||
></tiny-autocomplete> | ||||||
<div> | ||||||
<div class="title">medium:</div> | ||||||
<tiny-autocomplete | ||||||
size="medium" | ||||||
v-model="value" | ||||||
:fetch-suggestions="querySearch" | ||||||
placeholder="请输入内容" | ||||||
></tiny-autocomplete> | ||||||
</div> | ||||||
<div> | ||||||
<div class="title">default:</div> | ||||||
<tiny-autocomplete v-model="value" :fetch-suggestions="querySearch" placeholder="请输入内容"></tiny-autocomplete> | ||||||
</div> | ||||||
<div> | ||||||
<div class="title">small:</div> | ||||||
<tiny-autocomplete | ||||||
size="small" | ||||||
v-model="value" | ||||||
:fetch-suggestions="querySearch" | ||||||
placeholder="请输入内容" | ||||||
></tiny-autocomplete> | ||||||
</div> | ||||||
<div> | ||||||
<div class="title">small:</div> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect title text for mini size variant The title shows "small:" but this section demonstrates the "mini" size variant. - <div class="title">small:</div>
+ <div class="title">mini:</div> 📝 Committable suggestion
Suggested change
|
||||||
<tiny-autocomplete | ||||||
size="mini" | ||||||
v-model="value" | ||||||
:fetch-suggestions="querySearch" | ||||||
placeholder="请输入内容" | ||||||
></tiny-autocomplete> | ||||||
</div> | ||||||
Comment on lines
+3
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider refactoring repeated component structure The current implementation has significant code duplication. Consider refactoring using a v-for loop with a configuration array. <template>
<div class="demo-autocomplete">
- <div>
- <div class="title">medium:</div>
- <tiny-autocomplete
- size="medium"
- v-model="value"
- :fetch-suggestions="querySearch"
- placeholder="请输入内容"
- ></tiny-autocomplete>
- </div>
- <!-- ... other repeated blocks ... -->
+ <div v-for="size in sizes" :key="size">
+ <div class="title">{{ size }}:</div>
+ <tiny-autocomplete
+ :size="size === 'default' ? undefined : size"
+ v-model="value"
+ :fetch-suggestions="querySearch"
+ placeholder="请输入内容"
+ ></tiny-autocomplete>
+ </div>
</div>
</template> Add to the data section: data() {
return {
restaurants: [],
value: '',
sizes: ['medium', 'default', 'small', 'mini']
}
} |
||||||
</div> | ||||||
</template> | ||||||
|
||||||
|
@@ -72,4 +97,10 @@ export default { | |||||
.demo-autocomplete .tiny-autocomplete { | ||||||
width: 270px; | ||||||
} | ||||||
.demo-autocomplete > div { | ||||||
margin-top: 12px; | ||||||
} | ||||||
.demo-autocomplete > div > .title { | ||||||
line-height: 26px; | ||||||
} | ||||||
</style> |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -29,11 +29,12 @@ export default { | |||||||||||||
{ | ||||||||||||||
demoId: 'size', | ||||||||||||||
name: { | ||||||||||||||
'zh-CN': '输入框大小', | ||||||||||||||
'zh-CN': '尺寸', | ||||||||||||||
'en-US': 'Text box size' | ||||||||||||||
}, | ||||||||||||||
desc: { | ||||||||||||||
'zh-CN': '<p>可选择值为<code>medium</code>,<code>small</code>,<code>mini</code>。</p>', | ||||||||||||||
'zh-CN': | ||||||||||||||
'<p>可选择值为<code>medium</code>,<code>default</code>,<code>small</code>,<code>mini</code>,不传递就是默认尺寸。</p>', | ||||||||||||||
'en-US': '<p>The value can be <code>medium</code>, <code>small</code>, or <code>mini</code>.</p>' | ||||||||||||||
Comment on lines
+36
to
38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update English description to match Chinese changes. The Chinese description has been updated to include all size options ( Apply this change to sync the descriptions: 'zh-CN':
'<p>可选择值为<code>medium</code>,<code>default</code>,<code>small</code>,<code>mini</code>,不传递就是默认尺寸。</p>',
- 'en-US': '<p>The value can be <code>medium</code>, <code>small</code>, or <code>mini</code>.</p>'
+ 'en-US': '<p>The value can be <code>medium</code>, <code>default</code>, <code>small</code>, or <code>mini</code>. If not specified, the default size will be used.</p>' 📝 Committable suggestion
Suggested change
|
||||||||||||||
}, | ||||||||||||||
codeFiles: ['size.vue'] | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incorrect title text for mini size.
The title text shows "small:" for the mini-sized autocomplete component.
📝 Committable suggestion