Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

fix(preview): Markdown component layout breaks on copy-paste #3510

Merged
merged 2 commits into from Feb 8, 2019

Conversation

Bumbilo
Copy link
Member

@Bumbilo Bumbilo commented Jan 30, 2019

fixes: openshiftio/openshift.io#3972

  • Made the textarea instead of a contenteditable element
    screen shot 2019-01-30 at 11 30 19

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'beta' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-beta/328/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/328/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/328

Please review the job results and re-run the job by commenting [e2e-test-beta] if necessary.

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/326/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/326/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/326

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

import { Directive, ElementRef, HostListener, Input, Renderer2 } from '@angular/core';

@Directive({
selector: '[textAriaResize]',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename to textAreaResize

@HostListener('input', ['$event'])
resizeOnInput() {
const input = event.target as HTMLInputElement;
this.renderer.setStyle(this.element, 'height', '1px');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you set to 1px here only to set it to the scrollHeight immediately afterwards?

Copy link
Member Author

Choose a reason for hiding this comment

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

When I remove a line in the text area. scrollHeight has the same height and necessary to redefine it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok I understand why you're doing it now.
I think you need to ensure as well that overflow-y is set to hidden to account for the scrollbar appearing for OS / browser settings where a scrollbar consumes space. The scrollbar will flash as well as push the text resulting possibly in an incorrect calculation. Test this on several browsers.

I don't know if this is the best solution as it's doing a re-layout of the component on each input change. I can think of other ways to do this but they are certainly more involved with separate height calculations in another element. So if this works and doesn't give any negative experiences to the user (flashing, etc...), i'm ok with it.

#editorInput
[style.height.px]="editorInput.scrollHeight"
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this if you already have the text area resize directive?

textAreaElement = fixture.debugElement.query(By.directive(AreaSizeDirective));
});

it('textarea should have equel content height', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

equel => equal

);
});

it('the component should be identified by the directived', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

directived => directive

spyOn(textAreaElement.nativeElement, 'focus');
expect(textAreaElement).not.toBeNull();
fixture.detectChanges();
setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this timeout necessary?
Async tests need to use the done() protocol.


it('the component should be identified by the directived', () => {
textAreaElement.triggerEventHandler('input', null);
spyOn(textAreaElement.nativeElement, 'focus');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why add a focus spy if there's no assertions being made?

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/338/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/338/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/338

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

@Bumbilo Bumbilo changed the title fix(preview): Markdown component layout breaks on copy-paste [WIP]fix(preview): Markdown component layout breaks on copy-paste Jan 31, 2019
@Bumbilo Bumbilo changed the title [WIP]fix(preview): Markdown component layout breaks on copy-paste fix(preview): Markdown component layout breaks on copy-paste Jan 31, 2019
@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/339/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/339/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/339

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

@christianvogt
Copy link
Collaborator

@Bumbilo please test in firefox as I observed editing an existing description loses all new line characters in the text.

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/340/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/340/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/340

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

@christianvogt
Copy link
Collaborator

@Bumbilo
Tested in FireFox version:
image

Here's what happens:
markdown_ff

@Bumbilo
Copy link
Member Author

Bumbilo commented Feb 6, 2019

@christianvogt
Fixed
firefox

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/359/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/359/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/359

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'beta' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-beta/362/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/362/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/362

Please review the job results and re-run the job by commenting [e2e-test-beta] if necessary.

@christianvogt
Copy link
Collaborator

Your screen cap shows issues with lists showing up. I tested locally in chrome and FF and experienced the same issue. I cannot create markdown lists anymore.

- Made textaret instead of a contenteditable element
@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/361/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/361/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/361

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'beta' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-beta/364/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/364/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/364

Please review the job results and re-run the job by commenting [e2e-test-beta] if necessary.

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'beta' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-beta/369/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/369/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-beta/369

Please review the job results and re-run the job by commenting [e2e-test-beta] if necessary.

@centos-ci
Copy link
Collaborator

The E2E smoke test with feature level set to 'released' failed.

Link URL
job log https://ci.centos.org/job/devtools-fabric8-ui-e2e-smoketest-released/366/console
failure message http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/366/failures.txt
artifacts http://artifacts.ci.centos.org/devtools/e2e/devtools-fabric8-ui-e2e-smoketest-released/366

Please review the job results and re-run the job by commenting [e2e-test-released] if necessary.

@christianvogt christianvogt merged commit 18429cb into fabric8-ui:master Feb 8, 2019
@fabric8cd
Copy link
Contributor

🎉 This PR is included in version 5.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown component layout breaks on copy-paste
4 participants