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 #7194 Editor errors on Visualize are broken #7702

Merged
merged 6 commits into from
Jul 27, 2016

Conversation

ppisljar
Copy link
Member

fix for #7194 - editor errors on visualize are broken

updated edtor.less file to show error icon in the same style as the buttons next to it.

@Bargs
Copy link
Contributor

Bargs commented Jul 12, 2016

Functionally looks good to me, but let's take this as an opportunity to clean up the css based on @cjcenizal's guide: #7364

@Bargs Bargs assigned ppisljar and unassigned Bargs Jul 12, 2016
@ppisljar
Copy link
Member Author

@cjcenizal could you please review what i did so far before i continue ...

  • i renamed classes to follow your guide ... but i am not 100% i understood correctly:
    -- using camel case for component names
    -- using __ for subcomponents
    -- using -- for modifiers
  • replaced some of the html element selectors with class name selectors

if i understood correctly i dont need to take bootstrap out now, we'll be doing this gradually ? (since quite a lot of styles in this file are bootstrap modifiers)

please be aware that this is still work in progress, but i would fell better if i would know i am going to the right dirrection.

@cjcenizal
Copy link
Contributor

cjcenizal commented Jul 13, 2016

@ppisljar You nailed the new naming convention! Thanks for doing this. I think this is great in this PR, but in the future I think it's better to should hold off on these kinds of "mass-renaming" changes for now, for a couple reasons...

  1. I'm concerned about introducing two naming conventions in a single codebase. I think this might make things more confusing for developers.
  2. The ROI is pretty low, especially considering many of our styles need to be completely rethought as reusable UI components, which will require many class names and properties to change dramatically.

So I think it's OK if we stick with the existing kebab-case naming convention for components that already exist in Kibana and only apply the new naming convention for new components (either created in Kibana or in the new Kibana UI Framework I'm working on).

Instead of applying the new naming convention, I think more high-value changes to our CSS would be to reduce specificity (which has the added benefit of simplifying our styles). In this case, lines 11-35 of _editor.less contains numerous nested selectors, each of which introduces specificity. It's easy pretty difficult to read. I would explore whether this specificity is necessary for overriding the bootstrap navbar styles, or whether you can introduce classes with lower specificity that accomplish the same result.

Also, you're right that the migration away from bootstrap will be gradual, so you don't need to worry about that here.

@@ -1,6 +1,6 @@
<div class="vis-editor-agg-editor-advanced-toggle">
<div class="visEditorAgg__editor-advanced-toggle">
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically this should be visEditorAgg__editorAdvancedToggle, but it really doesn't matter per my comment re mass name-changes.

@cjcenizal
Copy link
Contributor

cjcenizal commented Jul 13, 2016

I opened up the inspector and checked out how the styles on line 11-35 of _editor.less were working.

image

I noticed a few interesting things:

  1. The subnav class doesn't seem to be doing anything! It wasn't showing up as a selector in the inspector's styles tab, and I grepped kibana source and couldn't find it defined anywhere.
  2. The over-reliance on the active class was causing problems, since it only added a couple styles to the element it was directly applied to, but was used to add styles implicitly to child elements.

So I untangled the nested selectors by creating a few unique classes, and using !important where necessary to override styles inherited by Bootstrap.

// _editor.less

.visEditor {
  .flex-parent();

  .btn-xs {
    line-height: 1.3;
  }

  /* ... */
}

  /**
   * 1. TODO: Override bootstrap styles. Remove !important once we're rid of bootstrap.
   */
  .visEditorSubNavLink {
    padding: 4px 10px 5px 10px !important; /* 1 */
    color: @kibanaGray2 !important; /* 1 */

    &.is-vis-editor-sub-nav-link-selected {
      border-bottom: 2px solid @kibanaGray2;
      color: @kibanaGray1;
      background-color: #f6f6f6;

      &:before {
        display: none;
      }

      &:hover {
        background-color: transparent;
      }
    }
  }

  /**
   * 1. TODO: Override bootstrap styles. Remove !important once we're rid of bootstrap.
   */
  .visEditorSubNavLink--danger {
    color: @vis-editor-navbar-error-state-color !important; /* 1 */
    background-color: @vis-editor-navbar-error-state-bg;

    &:hover {
      background-color: darken(@vis-editor-navbar-error-state-bg, 12%) !important; /* 1 */
    }
  }
<!-- sidebar.html -->

    <nav class="navbar navbar-default subnav">
      <div class="container-fluid">

        <!-- tabs -->
        <ul class="nav navbar-nav">
          <li ng-show="sidebar.showData">
            <a
              class="navbar-link visEditorSubNavLink"
              ng-class="{'is-vis-editor-sub-nav-link-selected': sidebar.section == 'data'}"
              ng-click="sidebar.section='data'"
            >
              @Data
            </a>
          </li>
          <li>
            <a
              class="navbar-link visEditorSubNavLink"
              ng-class="{'is-vis-editor-sub-nav-link-selected': sidebar.section == 'options'}"
              ng-click="sidebar.section='options'"
            >
              Options
            </a>
          </li>
        </ul>

        <!-- controls -->
        <ul class="nav navbar-nav navbar-right">
          <li ng-if="visualizeEditor.softErrorCount() > 0"
            disabled
            tooltip="{{ visualizeEditor.describeErrors() }}" tooltip-placement="bottom" tooltip-popup-delay="400" tooltip-append-to-body="1"
          >
            <a class="navbar-link visEditorSubNavLink visEditorSubNavLink--danger">
              <i class="fa fa-warning"></i>
            </a>
          </li>
          <li tooltip="Apply changes" tooltip-placement="bottom" tooltip-popup-delay="400" tooltip-append-to-body="1">
            <button class="btn-success navbar-btn-link"
              type="submit"
              ng-disabled="!vis.dirty">

              <i class="fa fa-play"></i>
            </button>
          </li>
          <li tooltip="Discard changes" tooltip-placement="bottom" tooltip-popup-delay="400" tooltip-append-to-body="1">
            <button class="btn-default navbar-btn-link"
              ng-disabled="!vis.dirty"
              ng-click="resetEditableVis()">

              <i class="fa fa-close"></i>
            </button>
          </li>
        </ul>
      </div>
    </nav>

As an added bonus, this fixes the styles, which I believe are currently "broken" (because Bootstrap is winning the specificity wars against some of the current selectors, so they're not all taking effect):

image

I can also make a PR into this branch if you want to see the diff more clearly. Just let me know.

@ppisljar
Copy link
Member Author

@cjcenizal ok i reverted back to the old naming convention and i put in your suggestions on how to reduce specificity. i also removed navbar-link class as it seemed its not needed anymore.

please let me know if this is going into the right direction.

@@ -1,5 +1,5 @@
<!-- header -->
<div class="vis-editor-agg-header">
<div class="visEditorAggHeader">
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to revert these class names back to the original snake-case versions in all of the markup too.

@cjcenizal
Copy link
Contributor

@ppisljar Left a couple comments! I can continue reviewing after they're addressed.

@ppisljar
Copy link
Member Author

sorry seems i messed up the commit ... i think it should be ok now.

@cjcenizal
Copy link
Contributor

jenkins, test this

<a class="navbar-link active" ng-click="sidebar.section='data'">Data</a>
<a class="vis-editor-subnav-link"
ng-class="{'is-vis-editor-sub-nav-link-selected': sidebar.section == 'data'}"
ng-click="sidebar.section='data'">Data</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, the attributes should all be on their own lines, the > of the opening tag should be on its own line, and the text and closing tag should be on their own lines:

<a
  class="vis-editor-subnav-link"
  ng-class="{'is-vis-editor-sub-nav-link-selected': sidebar.section == 'data'}"
  ng-click="sidebar.section='data'"
>
  Data
</a>

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm checking some of the other .html files and i cant find this anywhere (last > in a seperate line) ...
also my editor (webstorm) wont put > in line with <a (no indent) if i put it in a seperate line ....
would it be possible to configure .eseditorconfig and .eslint to follow this style ?

also could you update html style guide with this information:

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey Peter, the most recent version of the style guide exemplifies this in the examples. Should I update the descriptions to point this out more, or do you think this is enough?

This is a pretty recent change to the style guide. You can check out this PR for some context.

I'm using Sublime, so I'm not sure why WebStorm would be unhappy with that formatting... is this something you can look into fixing on your end? Let me know if you want to Zoom about this and tackle it together.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks CJ, im not sure how i managed to open the old style guide :) i managed to get webstorm working with it. I updated whole sidebar.html to follow the new style guide, can you please check if it looks ok ?

i still wonder if it would be possible to make a precommit check to enforce this (like we do with eslint) ?

@cjcenizal
Copy link
Contributor

jenkins, test this

class="vis-editor-subnav-link"
g-class="{'is-vis-editor-sub-nav-link-selected': sidebar.section == 'data'}"
g-click="sidebar.section='data'"
>Data</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be more maintainable if we separate the opening and closing tags from the content:

>
  Data
</a>

I think this consistency will let us change the content, e.g. adding more text, adding new elements, without having to add and remove new lines depending on how much content there is. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

i agree

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wait, I found a couple typos here... on lines 21 and 22, it looks like ng-class and ng-click got turned into g-class and g-click.

@cjcenizal
Copy link
Contributor

I just have 1 suggestion. Looks great overall! I agree that it would be great to get a linter to help us with these rules. I haven't been able to find one so far but I'll keep looking.

@cjcenizal
Copy link
Contributor

LGTM! Just gotta make sure the tests pass.

@cjcenizal
Copy link
Contributor

jenkins, test this

@ppisljar ppisljar merged commit c226848 into elastic:master Jul 27, 2016
@ppisljar ppisljar deleted the fix/7194 branch July 27, 2016 19:12
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
fix elastic#7194 Editor errors on Visualize are broken

Former-commit-id: c226848
cee-chen added a commit that referenced this pull request May 3, 2024
`v94.1.0-backport.0` ⏩ `v94.2.1-backport.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

##
[`v94.2.1-backport.0`](https://github.com/elastic/eui/releases/v94.2.1-backport.0)

**This is a backport release only intended for use by Kibana.**

- Reverted the `EuiFlexGroup`/`EuiFlexItem` `component` prop feature due
to Kibana typing issues

## [`v94.2.1`](https://github.com/elastic/eui/releases/v94.2.1)

**Bug fixes**

- Fixed an `EuiTabbedContent` edge case bug that occurred when updated
with a completely different set of `tabs`
([#7713](elastic/eui#7713))
- Fixed the `@storybook/test` dependency to be listed in
`devDependencies` and not `dependencies`
([#7719](elastic/eui#7719))

## [`v94.2.0`](https://github.com/elastic/eui/releases/v94.2.0)

- Updated `getDefaultEuiMarkdownPlugins()` to allow excluding the
following plugins in addition to `tooltip`:
([#7676](elastic/eui#7676))
  - `checkbox`
  - `linkValidator`
  - `lineBreaks`
  - `emoji`
- Updated `EuiSelectable`'s `isPreFiltered` prop to allow passing a
configuration object, which allows disabling search highlighting in
addition to search filtering
([#7683](elastic/eui#7683))
- Updated `EuiFlexGroup` and `EuiFlexItem` prop types to support passing
any valid React component type to the `component` prop and ensure proper
type checking of the extra props forwarded to the `component`.
([#7688](elastic/eui#7688))
- Updated `EuiSearchBar` to allow the `@` special character in query
string searches ([#7702](elastic/eui#7702))
- Added a new, optional `optionMatcher` prop to `EuiSelectable` and
`EuiComboBox` allowing passing a custom option matcher function to these
components and controlling option filtering for given search string
([#7709](elastic/eui#7709))

**Bug fixes**

- Fixed an `EuiPageTemplate` bug where prop updates would not cascade
down to child sections
([#7648](elastic/eui#7648))
- To cascade props down to the sidebar, `EuiPageTemplate` now explicitly
requires using the `EuiPageTemplate.Sidebar` rather than
`EuiPageSidebar`
- Fixed `EuiFieldNumber`'s typing to accept an icon configuration shape
([#7666](elastic/eui#7666))
- Fixed `EuiFieldText` and `EuiFieldNumber` to render the correct
paddings for icon shapes set to `side: 'right'`
([#7666](elastic/eui#7666))
- Fixed `EuiFieldText` and `EuiFieldNumber` to fully ignore
`icon`/`prepend`/`append` when `controlOnly` is set to true
([#7666](elastic/eui#7666))
- Fixed `EuiColorPicker`'s input not setting the correct right padding
for the number of icons displayed
([#7666](elastic/eui#7666))
- Visual fixes for `EuiRange`s with `showInput`:
([#7678](elastic/eui#7678))
  - Longer `append`/`prepend` labels no longer cause a background bug
  - Inputs can no longer overwhelm the actual range in width
- Fixed a visual text alignment regression in `EuiTableRowCell`s with
the `row` header scope
([#7681](elastic/eui#7681))
- Fixed `toolTipProps` type on `EuiSuperUpdateButton` to use
`Partial<EuiToolTipProps>`
([#7692](elastic/eui#7692))
- Fixes missing prop type for `popperProps` on `EuiDatePicker`
([#7694](elastic/eui#7694))
- Fixed a focus bug with `EuiDataGrid`s with `leadingControlColumns`
when moving columns to the left/right
([#7701](elastic/eui#7701))
([#7698](elastic/eui#7698))
- Fixed `EuiSuperDatePicker` to validate date string with respect of
locale on `EuiAbsoluteTab`.
([#7705](elastic/eui#7705))
- Fixed a visual bug with `EuiSuperDatePicker`'s absolute tab on small
mobile screens ([#7708](elastic/eui#7708))
- Fixed i18n of empty and loading state messages for the
`FieldValueSelectionFilter` component
([#7718](elastic/eui#7718))

**Dependency updates**

- Updated `@hello-pangea/dnd` to v16.6.0
([#7599](elastic/eui#7599))
- Updated `remark-rehype` to v8.1.0
([#7601](elastic/eui#7601))

**Accessibility**

- Improved `EuiBasicTable` and `EuiInMemoryTable`'s selection checkboxes
to have unique aria-labels per row
([#7672](elastic/eui#7672))
- Added `aria-valuetext` attributes to `EuiRange`s with tick labels for
improved screen reader UX
([#7675](elastic/eui#7675))
- Updated `EuiAccordion` to keep focus on accordion trigger instead of
moving to content on click/keypress
([#7696](elastic/eui#7696))
- Added `aria-disabled` attribute to `EuiHorizontalSteps` when status is
"disabled" ([#7699](elastic/eui#7699))

---------

Co-authored-by: Tomasz Kajtoch <tomasz.kajtoch@elastic.co>
cee-chen added a commit that referenced this pull request May 8, 2024
`v93.6.0` ⏩ `v93.6.0-backport.0`

---

##
[`v93.6.0-backport.0`](https://github.com/elastic/eui/releases/v93.6.0-backport.0)

**This is a backport release only intended for use by Kibana.**

- Updated `EuiSearchBar` to allow the `@` special character in query
string searches ([#7702](elastic/eui#7702))

**Bug fixes**

- Fixed a focus bug with `EuiDataGrid`s with `leadingControlColumns`
when moving columns to the left/right
([#7701](elastic/eui#7701))
([#7698](elastic/eui#7698))

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
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.

3 participants