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(components): [carousel] height is adaptive when height is auto #11392

Closed
wants to merge 29 commits into from
Closed

feat(components): [carousel] height is adaptive when height is auto #11392

wants to merge 29 commits into from

Conversation

qq282126990
Copy link
Contributor

@qq282126990 qq282126990 commented Feb 2, 2023

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

@pull-request-triage
Copy link

👋 @qq282126990, thank you for contributing element-plus.

  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Hello @qq282126990, thank you for contributing to element-plus, please see our guideline to see how to make contribution

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

🧪 Playground Preview: https://element-plus.run/?pr=11392
Please comment the example via this playground if needed.

@qq282126990
Copy link
Contributor Author

example url

https://element-plus.run/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cCBsYW5nPVwidHNcIj5cbmltcG9ydCB7IHJlZiwgdmVyc2lvbiBhcyB2dWVWZXJzaW9uIH0gZnJvbSAndnVlJ1xuaW1wb3J0IHsgdmVyc2lvbiBhcyBFcFZlcnNpb24gfSBmcm9tICdlbGVtZW50LXBsdXMnXG5pbXBvcnQgeyBFbGVtZW50UGx1cyB9IGZyb20gJ0BlbGVtZW50LXBsdXMvaWNvbnMtdnVlJ1xuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPGVsLWNhcm91c2VsIGhlaWdodD1cImF1dG9cIiBhdXRvcGxheT5cbiAgICA8ZWwtY2Fyb3VzZWwtaXRlbSBzdHlsZT1cImhlaWdodDogMTAwcHhcI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G4gIH0pXG59IiwiX28iOnsic2hvd0hpZGRlbiI6dHJ1ZSwic3R5bGVTb3VyY2UiOiJodHRwczovL3ByZXZpZXctMTEzOTItZWxlbWVudC1wbHVzLnN1cmdlLnNoL2J1bmRsZS9pbmRleC5jc3MifX0=

@tolking tolking changed the title fix(components): [carousel] Added function: height is adaptive when height is auto feat(components): [carousel] height is adaptive when height is auto Feb 2, 2023
@tolking tolking requested a review from a team February 2, 2023 08:37
@jw-foss
Copy link
Member

jw-foss commented Feb 2, 2023

I think the height can be set to auto by default, and the user needs to manually set it when the user needs to set the height

Just so you know that there were users who use this component and the changes you made might change the default behavior for those users per @btea's question above. Marking this behind a flag would be more flexible.

@qq282126990
Copy link
Contributor Author

ok, I feel that I need to add a new attribute named auto-height to delete and modify height to 'auto'

@tolking
Copy link
Member

tolking commented Feb 2, 2023

I don't think it is necessary to add new attributes, the default value of height is still ''. This PR has no breaking change and will not affect previous users

@qq282126990
Copy link
Contributor Author

我认为没有必要添加新的属性,默认值height仍然是''。本次 PR 没有 BC,不会影响之前的用户

So should I keep my original judgment?

@qq282126990
Copy link
Contributor Author

@jw-foss Using the test case, I don’t know why the height of the element cannot be obtained

image

image

@qq282126990
Copy link
Contributor Author

In addition to avoid the first rendering height of 0 should need to add a nextTick

image

@qq282126990
Copy link
Contributor Author

image

@qq282126990
Copy link
Contributor Author

图像

image

@qq282126990
Copy link
Contributor Author

qq282126990 commented Feb 3, 2023

@qq282126990感谢您贡献代码 LGTM,我留下了一些评论供您考虑。我想请您针对您的更改添加一个测试用例。如果您有任何问题,请告诉我👍

hello, Here is the test case I wrote

image

One problem is that running the test case carousel-item cannot get offsetHeight

image

@jw-foss

@Flourad
Copy link

Flourad commented Apr 10, 2023

这个特性可用了么?

@btea
Copy link
Collaborator

btea commented Apr 10, 2023

hello, Here is the test case I wrote

image

One problem is that running the test case carousel-item cannot get offsetHeight

image

This seems to be a jsdom bug, refer here.

@qq282126990
Copy link
Contributor Author

ok ,i see

@btea
Copy link
Collaborator

btea commented Apr 10, 2023

@qq282126990 There seems to be a conflict in the code, can you fix it?

@qq282126990
Copy link
Contributor Author

ok

@qq282126990 qq282126990 closed this by deleting the head repository Apr 10, 2023
@qq282126990
Copy link
Contributor Author

Hello, there may be problems with the previous branch, I recreated a new branch, please check the pull request

#12388

@btea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants