Skip to content

feat(config): Add option in config to set global tooltip and popover boundary #3229

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

Merged
merged 18 commits into from
May 3, 2019

Conversation

AlanRezende
Copy link
Contributor

@AlanRezende AlanRezende commented May 2, 2019

Describe the PR

A clear and concise description of what the pull request does.

PR checklist

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Enhancement
  • ARIA accessibility
  • Documentation update
  • Other (please describe)

Does this PR introduce a breaking change? (check one)

  • No
  • Yes (please describe)

The PR fulfills these requirements:

  • It's submitted to the dev branch, not the master branch
  • When resolving a specific issue, it's referenced in the PR's title (i.e. [...] (fixes #xxx[,#xxx]), where "xxx" is the issue number)
  • It should address only one issue or feature. If adding multiple features or fixing a bug and adding a new feature, break them into separate PRs if at all possible.
  • The title should follow the Conventional Commits naming convention (i.e. fix(alert): not alerting during SSR render, docs(badge): update pill examples, fix typos, chore: fix typo in README, etc). This is very important, as the CHANGELOG is generated from these messages.

If new features/enhancement/fixes are added or changed:

  • Includes documentation updates (including updating the component's package.json for slot and event changes)
  • New/updated tests are included and passing (if required)
  • Existing test suites are passing
  • The changes have not impacted the functionality of other components or directives
  • ARIA Accessibility has been taken into consideration (Does it affect screen reader users or keyboard only users? Clickable items should be in the tab index, etc.)

If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

@codecov
Copy link

codecov bot commented May 2, 2019

Codecov Report

Merging #3229 into dev will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #3229      +/-   ##
==========================================
+ Coverage   99.16%   99.16%   +<.01%     
==========================================
  Files         214      214              
  Lines        3961     3967       +6     
  Branches     1161     1161              
==========================================
+ Hits         3928     3934       +6     
  Misses         26       26              
  Partials        7        7
Impacted Files Coverage Δ
src/utils/config.js 100% <ø> (ø) ⬆️
src/mixins/toolpop.js 100% <ø> (ø) ⬆️
src/directives/tooltip/tooltip.js 100% <ø> (ø) ⬆️
src/directives/popover/popover.js 100% <ø> (ø) ⬆️
src/utils/tooltip.class.js 92.21% <ø> (ø) ⬆️
src/components/tooltip/tooltip.js 100% <100%> (ø) ⬆️
src/components/popover/popover.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63c4361...1f68bca. Read the comment docs.

@tmorehouse
Copy link
Member

This should probably be made to work for both the directive and the component versions (using the same BTooltip key in the config for both directive and component versions). As well, there should be a similar option for popovers (using the BPopover as they key).

Copy link
Member

@tmorehouse tmorehouse left a comment

Choose a reason for hiding this comment

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

Thanks for this.

Could you make this also apply to the b-tooltip component? They should use the same BTooltip` key in the config.

As well, it would be nice to have this work as well for popovers, using the BPopover config key.

@AlanRezende
Copy link
Contributor Author

Hi, I will add support for the components now. Since the popover and tooltip use a Mixin, It will be best to implement in the mixin toolpop or in each component?

@tmorehouse
Copy link
Member

@AlanRezende The prop boundary is defined in the mixin at https://github.com/AlanRezende/bootstrap-vue/blob/dev/src/mixins/toolpop.js#L62-L67

But the Miin is shared between BTooltip and BPopover, so in order to get the config value default unique for each, the individual components will need to have their own boundary prop defined (and then remove the boundary from the Mixin props.

@AlanRezende
Copy link
Contributor Author

That was what I figured out and didi exactly what you describe. But I have a problem.

With the directives all works fine, I`m using nuxt to set new values in config.

With the components, not so much, if in dev I set new values in my dev config and rebuild all, it updates, but if I set in nuxt config nothing changes.

Is there some aditional code to make the directives work with the given configs?

@tmorehouse
Copy link
Member

tmorehouse commented May 3, 2019

Ah, that is because the default value is being evaluated when the modal is loaded, not at runtime.

I'll suggest a fix in a few moments.

EDIT: wrong train of thought for me.

@tmorehouse
Copy link
Member

Could you provide an example of your nuxt config you are using?

For the components, make sure you are using:

    boundary: {
      // String: scrollParent, window, or viewport
      // Element: element reference
      type: [String, HTMLElement],
      default: () => getComponentConfig(...)
    },

and also include the HTMLElement polyfil (needed for SSR, as Node doesn't support HTMLElement) at the top:

import { HTMLElement } from '../utils/safe-types'

@AlanRezende
Copy link
Contributor Author

All working now wi the nuxt config:

bootstrapVue: {
    bootstrapCSS: false, // Or `css: false`
    bootstrapVueCSS: false, // Or `bvCSS: false`
    config: {
      BTooltip: {
        boundary: 'window'
      },
      BPopover: {
        boundary: 'window'
      }
    }
  },

Care to explain why on component I had to use () => getComponentConfig(...) while in directive getComponentConfig(...) worked fine?

is it better to always use () => getComponentConfig(...)?

@tmorehouse
Copy link
Member

tmorehouse commented May 3, 2019

In the directives, the config is generated on demand in the bind function

For props, if you didn't use hte () => ... nomenclature, the result of getComponentConfig runs (is evaluated) immediately when the module is loaded/imported. Setting the default to a function allows it to be evaluated lazily on first use of the component, to ensure the config is loaded before the component definition is evaluated. (as prop defaults can be the result of a function)

Since in the directive version everything is wrapped in functions, we didn't need to use () => ..., as they are lazy evaluated on first use.

@tmorehouse tmorehouse changed the title feat(config): Add option in config to set global tooltip boundary feat(config): Add option in config to set global tooltip and popover boundary May 3, 2019
@AlanRezende
Copy link
Contributor Author

I can confirm boundaryPadding is working based on config values (nuxt config used)

@AlanRezende
Copy link
Contributor Author

Do we need to change anything else?

@tmorehouse tmorehouse removed the Status: Changes Needed Pull request needs changes label May 3, 2019
@tmorehouse
Copy link
Member

I think we are good to go for a merge.

@tmorehouse tmorehouse merged commit 00e4fc9 into bootstrap-vue:dev May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants