-
Notifications
You must be signed in to change notification settings - Fork 86
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
Modal Adjust to Input Size #590
Modal Adjust to Input Size #590
Conversation
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.
Hi! @galovdev This is looking better! But we still need to find a way how to update the height of the content, I will check with the team for further Ideas. Also, I see there are some linting errors, you can fix them with yarn run lint-fix
and also we need to update the CHANGELOG.md file with the update of this PR.
lib/KModal.vue
Outdated
const textInputs = this.$refs.content.querySelectorAll('input[type="text"], textarea'); | ||
textInputs.forEach(input => { | ||
input.addEventListener('input', () => { | ||
this.$refs.content.style.height = 'auto'; |
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.
The reason we should not add listeners to the inputs is that inputs are not just the ones that will grow or shrink, this can be anything that are conditionally rendered within the modal, so this solution will not work for modals that have a form that could (conditionally) have warnings and errors, just to give an example.
Check this video I recorded running this PR:
Compartir.pantalla.-.2024-03-26.08_15_43.mp4
This is because this solution is not general for all use cases. Also, we should try to avoid setting the content height to auto, as this could cause too many reflows.
We need to think a way to track the actual height of the content and update accordingly only when there are more than 8px of difference.
Hi @galovdev I talked with the team, and we are going to take the approach of keep it simple, and better set an Also, we will need to retarget the PR to the |
Give me till monday to make the changes and re'target the branch, ill be out this weekend. |
Hi! @galovdev How are you? Have you been able to advance in the PR? I'm not sure if maybe someway I misdirected you, but we are expecting in this PR that we clean up the JS code related to the Also we will need to retarget the PR to the Let me know if you have any question :). |
lib/KModal.vue
Outdated
@@ -216,19 +208,15 @@ | |||
modalWidth() { | |||
if (this.size === SIZE_SM) return '300px'; | |||
if (this.size === SIZE_MD) return '450px'; | |||
if (this.size === SIZE_LG) return '100%'; |
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.
It looks like we accidentally deleted this line and we need to bring it back.
Hi @galovdev! How are you? Have you been able to advance in the PR? Let us know if there is something we can help with. |
ad92b9d
to
1fdcb5b
Compare
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.
Thank you @galovdev! Code looks good, and QA has confirmed that there are no regressions. Its good to go! 🎉.
Description
The modal now resizes like the description input every time the input size changes.
Issue addressed
Addresses #570
Before/after screenshots
Before:
After:
Grabacion.de.pantalla.2024-03-25.a.la.s.3.32.35.p.m.mov
Changelog
Steps to test
Testing checklist
After review
CHANGELOG.md