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

fix(VTextField): use intersect to recalculate elements width #9341

Merged
merged 2 commits into from
Dec 4, 2019

Conversation

Djaler
Copy link
Contributor

@Djaler Djaler commented Oct 13, 2019

fixes #9299

Description

Use IntersectionObserver (if it available) to recalculate element width after input becomes visible,

Motivation and Context

Cause they have zero width on mount in hidden state (inside expansion panel, for example)
#9299

How Has This Been Tested?

visually

Markup:

https://codepen.io/djaler/pen/oNNXywM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • The PR title is no longer than 64 characters.
  • The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and breaking changes).
  • My code follows the code style of this project.
  • I've added relevant changes to the documentation (applies to new features and breaking changes in core library)
  • I've added new examples to the kitchen (applies to new features and breaking changes in core library)

@Djaler
Copy link
Contributor Author

Djaler commented Oct 13, 2019

@johnleider this is improved version of #9300

dsseng
dsseng previously requested changes Oct 15, 2019
Copy link
Contributor

@dsseng dsseng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create corresponding tests

@johnleider
Copy link
Member

@Djaler Could you message me in the community please, https://community.vuetifyjs.com

@TravisBuddy
Copy link

TravisBuddy commented Nov 13, 2019

Hey @Djaler,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 35025550-12d9-11ea-b2b3-cdec09be7ce8

@Djaler
Copy link
Contributor Author

Djaler commented Nov 13, 2019

@johnleider I updated a code according to what we discussed. Also, @sh7dm, I added a test to the mixin

packages/vuetify/src/mixins/intersectable/index.ts Outdated Show resolved Hide resolved
@johnleider
Copy link
Member

@KaelWD can you look over the mixin for inaccuracies in typescript implementation.

@johnleider johnleider added C: VTextField VTextField T: bug Functionality that does not work as intended/expected and removed S: needs unit tests This PR needs unit tests labels Nov 20, 2019
@johnleider johnleider added this to the v2.1.x milestone Nov 20, 2019
@Djaler Djaler force-pushed the fix/9299-v-text-field-intersect branch from e71b995 to 33b2f67 Compare November 21, 2019 03:15
@MajesticPotatoe MajesticPotatoe dismissed stale reviews from dsseng and johnleider November 21, 2019 13:12

completed

@Djaler Djaler force-pushed the fix/9299-v-text-field-intersect branch from 64414b9 to 2f5b9fb Compare November 21, 2019 16:42
@Djaler
Copy link
Contributor Author

Djaler commented Nov 27, 2019

@johnleider can you check it?

@Djaler Djaler closed this Nov 27, 2019
@Djaler Djaler reopened this Nov 27, 2019
Copy link
Member

@johnleider johnleider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing this again, I'm not sure why we are re-rolling up the intersectable functionality. We already have the v-intersect directive. We could essentially just hook into the render function and dynamically add the directive.

packages/vuetify/src/components/VTextField/VTextField.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,43 @@
import Vue from 'vue'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to:

// Utilities
import { consoleWarn } '../../util/console'

// Types
import Vue from 'vue'

packages/vuetify/src/mixins/intersectable/index.ts Outdated Show resolved Hide resolved
packages/vuetify/src/mixins/intersectable/index.ts Outdated Show resolved Hide resolved
packages/vuetify/src/mixins/intersectable/index.ts Outdated Show resolved Hide resolved
@Djaler
Copy link
Contributor Author

Djaler commented Nov 28, 2019

@johnleider how can we add directive from mixin?

@KaelWD
Copy link
Member

KaelWD commented Nov 29, 2019

@KaelWD can you look over the mixin for inaccuracies in typescript implementation.

It's alright. Could make the options type safe by being a wrapping function instead of a mixin factory, but that gets pretty complicated.

how can we add directive from mixin?

Yeah I don't think you really can. The mixin could have everything else though and the implementing component would just have to make sure to use the directive somewhere.

EDIT: maybe

mounted () {
  Intersect.inserted(this.$el, options)
}
destroyed () {
  Intersect.unbind(this.$el)
}

@Djaler
Copy link
Contributor Author

Djaler commented Nov 29, 2019

The mixin could have everything else though and the implementing component would just have to make sure to use the directive somewhere.

Do you mean, in implementing component we will have something like

directives: [
          {
            name: 'intersect',
            value: {
              handler: this.onObserve,
            },
          },
        ],

, where onObserve provided by mixin?

@KaelWD
Copy link
Member

KaelWD commented Nov 29, 2019

Yeah. See my edit for another idea.

@Djaler
Copy link
Contributor Author

Djaler commented Nov 29, 2019

mounted () {
  Intersect.inserted(this.$el, options)
}
destroyed () {
  Intersect.unbind(this.$el)
}

Do you mean to get rid of mixin at all?

@KaelWD
Copy link
Member

KaelWD commented Nov 29, 2019

No, the mixin can do that.

@Djaler
Copy link
Contributor Author

Djaler commented Nov 29, 2019

Oh, I did not get it that Intersection.inserted is a way to initialize directive. Yeah, this could work

@Djaler Djaler force-pushed the fix/9299-v-text-field-intersect branch from 2f5b9fb to 3341a83 Compare November 29, 2019 18:41
@Djaler Djaler force-pushed the fix/9299-v-text-field-intersect branch from 3341a83 to 005e4d8 Compare November 29, 2019 18:43
@Djaler
Copy link
Contributor Author

Djaler commented Nov 29, 2019

@KaelWD @johnleider done

@Djaler
Copy link
Contributor Author

Djaler commented Dec 3, 2019

So what about it, guys?

@johnleider johnleider merged commit c34f35c into vuetifyjs:master Dec 4, 2019
@Djaler Djaler deleted the fix/9299-v-text-field-intersect branch December 4, 2019 18:54
@lock lock bot locked as resolved and limited conversation to collaborators Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: VTextField VTextField T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report] Incorrect text field size calculation inside expansion panel
5 participants