generated from react-component/footer
-
Notifications
You must be signed in to change notification settings - Fork 36
Fix/seo display all invisibly #40
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
Closed
huan-qiu
wants to merge
7
commits into
react-component:master
from
huan-qiu:fix/seo-display-all-invisibly
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
03285c0
fix: render full list for responsive mode with width set to 0, then c…
huan-qiu 43c5a07
fix: render but hide all items by max-width 0 when on first render un…
huan-qiu f52194b
test: update ssr test case
huan-qiu 709c9f3
chore: rename ssr.spec to seo.spec
huan-qiu 1bf2853
fix: should also render suffix item if any invisibly
huan-qiu 68bde93
test: add snapshot target suffix
huan-qiu cbf13ad
test: add cases for maxCount number and invalidate
huan-qiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Overflow.SEO invalidate number with suffix 1`] = ` | ||
<div | ||
class="" | ||
> | ||
<div | ||
class="" | ||
> | ||
Label 0 | ||
</div> | ||
<div | ||
class="" | ||
> | ||
Label 1 | ||
</div> | ||
<div | ||
class="" | ||
> | ||
Label 2 | ||
</div> | ||
<div | ||
class="" | ||
> | ||
Label 3 | ||
</div> | ||
<div | ||
class="rc-overflow-item-suffix" | ||
> | ||
<span> | ||
I am a suffix | ||
</span> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`Overflow.SEO maxCount number with suffix 1`] = ` | ||
<div | ||
class="rc-overflow" | ||
> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1" | ||
> | ||
Label 0 | ||
</div> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1" | ||
> | ||
Label 1 | ||
</div> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1" | ||
> | ||
Label 2 | ||
</div> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1" | ||
> | ||
Label 3 | ||
</div> | ||
<div | ||
class="rc-overflow-item rc-overflow-item-rest" | ||
style="opacity:1" | ||
> | ||
+ 2 ... | ||
</div> | ||
<div | ||
class="rc-overflow-item rc-overflow-item-suffix" | ||
style="opacity:1" | ||
> | ||
<span> | ||
I am a suffix | ||
</span> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`Overflow.SEO responsive 1`] = ` | ||
<div | ||
class="rc-overflow" | ||
> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1;order:0;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
Label 0 | ||
</div> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1;order:1;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
Label 1 | ||
</div> | ||
<div | ||
aria-hidden="true" | ||
class="rc-overflow-item rc-overflow-item-rest" | ||
style="opacity:0;height:0;overflow-y:hidden;order:9007199254740991;pointer-events:none;position:absolute;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
+ 0 ... | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`Overflow.SEO responsive with suffix 1`] = ` | ||
<div | ||
class="rc-overflow" | ||
> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1;order:0;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
Label 0 | ||
</div> | ||
<div | ||
class="rc-overflow-item" | ||
style="opacity:1;order:1;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
Label 1 | ||
</div> | ||
<div | ||
aria-hidden="true" | ||
class="rc-overflow-item rc-overflow-item-rest" | ||
style="opacity:0;height:0;overflow-y:hidden;order:9007199254740991;pointer-events:none;position:absolute;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
+ 0 ... | ||
</div> | ||
<div | ||
class="rc-overflow-item rc-overflow-item-suffix" | ||
style="opacity:1;order:9007199254740991;max-width:0;padding:0;margin:0;border-width:0;overflow-x:hidden" | ||
> | ||
<span> | ||
I am a suffix | ||
</span> | ||
</div> | ||
</div> | ||
`; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import Overflow from '../src'; | ||
import type { OverflowProps } from '../src'; | ||
|
||
interface ItemType { | ||
label: React.ReactNode; | ||
key: React.Key; | ||
} | ||
|
||
interface CaseConf { | ||
name: string; | ||
dataLength: number; | ||
maxCount: OverflowProps<ItemType>['maxCount']; | ||
suffix?: boolean; | ||
} | ||
|
||
function renderItem(item: ItemType) { | ||
return item.label; | ||
} | ||
|
||
describe('Overflow.SEO', () => { | ||
function getData(count: number) { | ||
return new Array(count).fill(undefined).map((_, index) => ({ | ||
label: `Label ${index}`, | ||
key: `k-${index}`, | ||
})); | ||
} | ||
|
||
beforeEach(() => { | ||
jest.useFakeTimers(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
const testCases: CaseConf[] = [ | ||
{ | ||
name: 'responsive', | ||
dataLength: 2, | ||
maxCount: 'responsive', | ||
}, | ||
{ | ||
name: 'responsive with suffix', | ||
dataLength: 2, | ||
maxCount: 'responsive', | ||
suffix: true, | ||
}, | ||
{ | ||
name: 'maxCount number with suffix', | ||
dataLength: 6, | ||
maxCount: 4, | ||
suffix: true, | ||
}, | ||
{ | ||
name: 'invalidate number with suffix', | ||
dataLength: 4, | ||
maxCount: 'invalidate', | ||
suffix: true, | ||
}, | ||
]; | ||
|
||
testCases.forEach(({ name, dataLength, maxCount: maxCountVal, suffix }) => { | ||
it(`${name}`, () => { | ||
const wrapper = render( | ||
<Overflow<ItemType> | ||
data={getData(dataLength)} | ||
renderItem={renderItem} | ||
maxCount={maxCountVal} | ||
suffix={suffix && <span> I am a suffix </span>} | ||
/>, | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这个不该删的,只是处理 full 的时候做坍缩。不是 full 的时候仍然是不渲染。overflow 不仅仅是 menu 在用。还有其他的响应时需求逻辑是不一样的。
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.
猴猴,我缩小了改动的区域,在 full 且需要responsive的时候才做坍缩。麻烦 review 这条哦:#41