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

[ML] Fix modal titles #147855

Merged
merged 6 commits into from
Jan 10, 2023
Merged

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Dec 20, 2022

An EUI change has caused modal titles to no longer be implicitly wrapped in a header tag.
This change adds a h2 to all modal titles.

Old
image

New
image

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@darnautov
Copy link
Contributor

@jgowdyelastic I reckon it's semantically incorrect putting the h1 header in a dialog. There is supposed to be only one h1 on a page and we already have it specified per page, e.g. "Trained Models", "Anomaly Explorer" etc. Hence I believe the dialog should be either h2 or h3 depending on what heading levels are present on a page and what section a particular dialog belongs to. To make it consistent we can specify h2 for all modal windows, WDYT?

@jgowdyelastic
Copy link
Member Author

@jgowdyelastic I reckon it's semantically incorrect putting the h1 header in a dialog. There is supposed to be only one h1 on a page and we already have it specified per page, e.g. "Trained Models", "Anomaly Explorer" etc. Hence I believe the dialog should be either h2 or h3 depending on what heading levels are present on a page and what section a particular dialog belongs to. To make it consistent we can specify h2 for all modal windows, WDYT?

The EUI examples use h1 (https://elastic.github.io/eui/#/layout/modal) but I agree that we should really only have one per page.
Updated to h2 in ca32f39

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

LGTM

@peteharverson
Copy link
Contributor

These changes look good, but it looks like titles aren't being styled correct for any EuiConfirmModal opened from an EuiFlyout.

For example:

image

Compared to one which hasn't been opened from a flyout:

image

@elastic/kibana-design is this a known issue for EuiConfirmModal opened from a flyout, or do we need to change the code in some way to ensure the title is styled correctly?

@1Copenut
Copy link
Contributor

@peteharverson Thank you for the ping on our Slack channel. If you pass a bare string or HTML tag as the children to EuiModalHeaderTitle, it will automatically wrap in an H1, which is the desired outcome.

The EUI team is working on a documentation update to spell out using H1 for modal titles today. After some discussion and reviews, we're recommending modals use H1 because it's a significant shift in user context. We want to visually and semantically convey this is a break in the previous flow, and we need your (user's) attention on this window for a moment.

@jgowdyelastic
Copy link
Member Author

@peteharverson Thank you for the ping on our Slack channel. If you pass a bare string or HTML tag as the children to EuiModalHeaderTitle, it will automatically wrap in an H1, which is the desired outcome.

@1Copenut Are you sure this is the case now? this is how it used to work, but after a recent eui change it no longer seems to do this, hence the reason we've created this PR.

@1Copenut
Copy link
Contributor

1Copenut commented Dec 21, 2022

@jgowdyelastic I took a second look and found the root cause. EUI PR #6321 removed a containing div and replaced it with an EuiTitle component on line 27 of the EuiModalHeaderTitle.

EuiTitle only clones its children prop and returns children with any additional CSS. When we (EUI) removed the div, the FormattedMessages were being rendered as is, without wrapping in an H1. Your changeset here restores the proper styling.

If there's time for another round of changes, I'd recommend swapping H2 for H1 to give semantic parity to the default EUI modal. Or if this patch needs to land quickly, can we add an improvement ticket to the backlog?

@jgowdyelastic
Copy link
Member Author

@1Copenut ok thanks.
I've switched it back to h1.
Do you have any thoughts about the strange EuiConfirmModal behaviour Pete reported in the comment above. It appears confirm modal title is wrong only when triggering the confirm modal from a flyout.

@1Copenut
Copy link
Contributor

Do you have any thoughts about the strange EuiConfirmModal behaviour Pete reported in the #147855 (comment) above. It appears confirm modal title is wrong only when triggering the confirm modal from a flyout.

Without seeing the source React code, I'm speculating a bit, but...

The EuiConfirmModal that has the small text might be passing a React component to the title prop, where the other one with larger (correct) text is passing a string to title. EuiConfirmModal passes title through to EuiModalHeaderTitle silently.

@peteharverson
Copy link
Contributor

Without seeing the source React code, I'm speculating a bit, but...

The EuiConfirmModal that has the small text might be passing a React component to the title prop, where the other one with larger (correct) text is passing a string to title. EuiConfirmModal passes title through to EuiModalHeaderTitle silently.

Yes, looks like the ones where we have the small text is because we are passing <FormattedMessage> to the title to handle the internationalization. We'd have to replace this by passing a string, for example

    title={i18n.translate(
      'xpack.ml.timeSeriesExplorer.deleteAnnotationModal.deleteAnnotationTitle',
      {
        defaultMessage: 'Delete this annotation?',
      }
    )}

Trying this out now leads me to a design question - this looks a bit odd where there is just a title and no child component:

image

compared to this, where I added a child <p>:

image

@elastic/kibana-design what do you think? Should we add a child component for all our EuiConfirmModal where we currently only have a title?

@mdefazio
Copy link
Contributor

mdefazio commented Jan 3, 2023

@elastic/kibana-design what do you think? Should we add a child component for all our EuiConfirmModal where we currently only have a title?

@peteharverson I don't think we need to force adding in text here unless it adds more value for the user. (See EUI Modal Guidelines). We also try to avoid saying 'Are you sure' (Writing guidelines) .

@jgowdyelastic
Copy link
Member Author

@peteharverson updated EuiConfirmModal titles in 87e0129

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 3.4MB 3.4MB +47.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jgowdyelastic

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested latest changes and LGTM

@jgowdyelastic jgowdyelastic merged commit 5c8b6f2 into elastic:main Jan 10, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jan 10, 2023
angorayc added a commit to angorayc/kibana that referenced this pull request Jan 10, 2023
commit fc3b886
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 10 14:02:01 2023 +0000

    replace alerts by severity table with lens

commit a1464c2
Merge: e0bdf32 076d60d
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 10 12:41:36 2023 +0000

    Merge branch 'histogram-with-lens' of github.com:angorayc/kibana into histogram-with-lens

commit e0bdf32
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 10 12:40:45 2023 +0000

    replace donut on alerts page

commit 076d60d
Merge: f5cb4e0 09e10b8
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 10 11:53:38 2023 +0000

    Merge branch 'main' of github.com:elastic/kibana into histogram-with-lens

commit f5cb4e0
Merge: 119dbe7 010f93b
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 10 11:15:40 2023 +0000

    Merge branch 'histogram-with-lens' of github.com:angorayc/kibana into histogram-with-lens

commit 09e10b8
Author: Angela Chuang <6295984+angorayc@users.noreply.github.com>
Date:   Tue Jan 10 11:13:21 2023 +0000

    [SecuritySolution] Replace donuts with Lens (elastic#148519)

    ## Summary

    This pr is a part of elastic#147261:
    Replace donut charts with Lens:
    This is behind feature flag `chartEmbeddablesEnabled `

    Items to verify:
    1. If the queries and filters from the global search box are applied.
    2. If the correct alert index is applied by different spaced.
    3. Visualization actions working correctly.

    Detection and Response dashboard:
    <img width="1662" alt="Screenshot 2023-01-09 at 09 21 56"
    src="https://user-images.githubusercontent.com/6295984/211275765-8177e9bd-3623-4bb2-b1d9-8a3044d523a0.png">

    Host details:
    <img width="1666" alt="Screenshot 2023-01-09 at 09 21 38"
    src="https://user-images.githubusercontent.com/6295984/211275770-be95353f-4d1b-410a-b7bf-b232692af1ab.png">

    User details:
    <img width="1662" alt="Screenshot 2023-01-09 at 09 21 19"
    src="https://user-images.githubusercontent.com/6295984/211275773-dd0bcaaf-58e6-404b-b010-d1c464cbd101.png">

    Network details:
    <img width="1663" alt="Screenshot 2023-01-09 at 09 20 47"
    src="https://user-images.githubusercontent.com/6295984/211275775-0fd39ac3-e977-44bd-bd40-304463dce613.png">

    Known issues:
    1. Not showing legend for alerts donut charts at the moment: There is a
    logic in Lens that it doesn't show the legend item if its value is zero.
    4. JS warnings triggered by incorrect state changed. Fixed by
    elastic#148552
    5. No label in the donut by default when open in Lens - Lens doesn't
    support displaying a label in the middle of the donut chart by default,
    so it is currently available in Security Solution.
    6. Applying filters or extra action while clicking the donut is not
    available atm

    ### Checklist

    Delete any items that are not applicable to this PR.

    - [x] [Unit or functional
    tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
    were updated or added to match the most common scenarios

    Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>

commit ef2faad
Author: Marco Antonio Ghiani <marcoantonio.ghiani01@gmail.com>
Date:   Tue Jan 10 10:39:50 2023 +0100

    [Infrastructure UI]: Add feedback button for hosts page (elastic#148555)

    ## 📓 Summary

    Closes elastic#148379

    This PR replaces the existing link to get feedback on the forum with a
    button that brings on a form with predefined questions on the Hosts
    page.

    ## 🧪 Testing

    Navigate to the `Hosts`view and click the top-right button saying "_Tell
    us what you think!_".

    <img width="1502" alt="solution"
    src="https://user-images.githubusercontent.com/34506779/211347429-c8f338c3-8bb0-4304-8b58-6d140e301554.png">

    Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
    Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>

commit 5c8b6f2
Author: James Gowdy <jgowdy@elastic.co>
Date:   Tue Jan 10 09:33:56 2023 +0000

    [ML] Fix modal titles (elastic#147855)

    An EUI change has caused modal titles to no longer be implicitly wrapped
    in a header tag.
    This change adds a `h2` to all  modal titles.

    **Old**
    <img width="824" alt="image"
    src="https://user-images.githubusercontent.com/22172091/208673148-3da918c4-f1d7-48c5-8afd-022b912b49fc.png">

    **New**
    <img width="857" alt="image"
    src="https://user-images.githubusercontent.com/22172091/208673087-1b8cba03-504b-4505-ac65-0fcfcce4b99b.png">

commit 010f93b
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 8 15:15:43 2022 +0000

    render histogram with lens

commit 119dbe7
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Sun Jan 8 10:02:57 2023 +0000

    fix types

commit 0891f07
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Sat Jan 7 23:39:27 2023 +0000

    unit test

commit d2023fa
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Sat Jan 7 23:32:23 2023 +0000

    fetch session id only when vis inabled

commit 82b4ddb
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Sat Jan 7 22:38:44 2023 +0000

    refetch

commit d896cb0
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Sat Jan 7 19:47:18 2023 +0000

    remove eslint comment

commit d619b30
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Sat Jan 7 19:19:41 2023 +0000

    unit tests

commit 075ef5f
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Jan 5 15:46:55 2023 +0000

    styling

commit 4d4a5cf
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Jan 5 15:16:54 2023 +0000

    update snapshot

commit aead88e
Merge: a91bf4f 1c5febb
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Jan 5 14:51:07 2023 +0000

    Merge branch 'histogram-with-lens' of github.com:angorayc/kibana into histogram-with-lens

commit a91bf4f
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Jan 5 14:50:39 2023 +0000

    update snapshot

commit 29da009
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Jan 5 14:42:32 2023 +0000

    fix types

commit 1c18042
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Jan 5 12:47:56 2023 +0000

    styling

commit 1c5febb
Author: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Date:   Tue Jan 3 17:43:29 2023 +0000

    [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

commit 73e17de
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 3 17:38:29 2023 +0000

    pass extra filters to Lens

commit 789c0c8
Merge: dfb9e8f 0c8c4d7
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 3 17:14:34 2023 +0000

    Merge branch 'main' of github.com:elastic/kibana into histogram-with-lens

commit dfb9e8f
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Jan 3 15:48:36 2023 +0000

    render rule preview with lens

commit c753bd8
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Fri Dec 30 16:02:53 2022 +0000

    add total alerts count

commit 785712e
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 29 18:26:50 2022 +0000

    replace alerts donut charts

commit c31b77d
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Wed Dec 28 11:08:34 2022 +0000

    fix unit tests

commit 7dbc50d
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Fri Dec 23 14:02:52 2022 +0000

    add unit tests

commit 1b50b16
Merge: 55f0cf2 03ddae8
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 14:15:02 2022 +0000

    Merge branch 'main' of github.com:elastic/kibana into histogram-with-lens

commit 55f0cf2
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 14:14:45 2022 +0000

    update snapshots

commit 153f139
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 12:46:22 2022 +0000

    add unit tests

commit da58b26
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 12:13:17 2022 +0000

    rename props

commit 26da70b
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 12:12:53 2022 +0000

    update events chart

commit 445cb99
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 11:44:13 2022 +0000

    clean up

commit 761998f
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 22 11:05:57 2022 +0000

    fix unit tests

commit 5fc4ece
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Wed Dec 21 17:36:39 2022 +0000

    fix types

commit 73424d7
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Wed Dec 21 17:01:40 2022 +0000

    add no data prompt

commit 0b18236
Merge: a07eefe 5f5291d
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Dec 20 17:07:17 2022 +0000

    Merge branch 'histogram-with-lens' of github.com:angorayc/kibana into histogram-with-lens

commit a07eefe
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Dec 20 17:06:32 2022 +0000

    extra actions

commit 84dce3f
Merge: b68afd1 53e42eb
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Dec 20 16:12:24 2022 +0000

    Merge branch 'main' of github.com:elastic/kibana into histogram-with-lens

commit 5f5291d
Author: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Date:   Tue Dec 20 15:21:19 2022 +0000

    [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

commit b68afd1
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Tue Dec 20 15:15:31 2022 +0000

    replace alerts histograms with Lens

commit 7b39762
Merge: 6376733 3192372
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Fri Dec 16 09:58:19 2022 +0000

    Merge branch 'main' of github.com:elastic/kibana into histogram-with-lens

commit 6376733
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Fri Dec 16 09:58:15 2022 +0000

    replace alert histograms with lens

commit 62bd659
Author: Angela Chuang <yi-chun.chuang@elastic.co>
Date:   Thu Dec 8 15:15:43 2022 +0000

    render histogram with lens
jennypavlova pushed a commit to jennypavlova/kibana that referenced this pull request Jan 13, 2023
An EUI change has caused modal titles to no longer be implicitly wrapped
in a header tag.
This change adds a `h2` to all  modal titles. 

**Old**
<img width="824" alt="image"
src="https://user-images.githubusercontent.com/22172091/208673148-3da918c4-f1d7-48c5-8afd-022b912b49fc.png">

**New**
<img width="857" alt="image"
src="https://user-images.githubusercontent.com/22172091/208673087-1b8cba03-504b-4505-ac65-0fcfcce4b99b.png">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting :ml release_note:fix v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants