-
Notifications
You must be signed in to change notification settings - Fork 27
Refactor EditableField and FadeText #8858
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
Conversation
✅ Deploy Preview for ilios-frontend ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
i believe there's a cleaner and simpler solution to the accessibility issue that this is addressing, which builds on most of these changes. please see jrjohnson#896 and #8858. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a minor fix in the test coverage, otherwise good.
|
|
||
| assert.false(this.expanded, 'text is not expanded'); | ||
| assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass); | ||
| assert.ok(component.enabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to await fadedSelector to be present.
| assert.ok(component.enabled); | |
| await waitFor(this.fadedSelector); | |
| assert.ok(component.enabled); |
| import { module, test } from 'qunit'; | ||
| import { setupRenderingTest } from 'test-app/tests/helpers'; | ||
| import { render, waitFor } from '@ember/test-helpers'; | ||
| import { render } from '@ember/test-helpers'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitFor is still needed.
| import { render } from '@ember/test-helpers'; | |
| import { render, waitFor } from '@ember/test-helpers'; |
Instead of passing options to the component and adding a handler to the container we can use a local modifier to handle the save and close keyboard interactions and pass that back to consumers of EditableField. This makes the API easier to understand as not applying the modifier will prevent any keyboard handing and allows us to remove an invalid interactive issue.
Using named blocks to extract some of the HTML handling from here and remove a few branches. Also removed the unused @showIcon option. WIP commit as more work will need to be done because now there is a text expand button inside the field editing button.
Using contextual components we can curry the values we need for controlling text fading and use them where we apply this component. I also found a way using css mask-image to fade out the text with the component itself instead of needing to do that everywhere we use it. These things combined let us wrap the EditableField inside the fade text so we get the editable behavior, but maintain the expand collapse buttons outside of the editable button. Taken all together we can remove a lot of duplicate code and rely solely on the FadeText component to do this work without needing to duplicate the HTML and styles elsewhere.
This has a tendency to fall out of date (as it did with removing froala and keeping this class here). Instead we can use the modifier directly on the controls as they won't appear in the DOM until they're ready. This takes away some magic and simplifies the component.
When editable field is passed things that look empty it is impossible to click and edit them. I've slightly changed the original behavior and used the icon only if the click prompt isn't passed.
We only use this in one place, but it's nice to have.
Automatically remove links from text, but allow them to be preserved if needed. Can be invoked on the FadeText component or on the yielded contextual component as needed. Mostly we're removing them, but I kept links in when in a read only display of the faded text.
The resizeObserver fires asynchronously in browser code so tests may run before it has a chance to detect the size and send it. This can cause intermittent test failures. I've added a test waiter to FadeText to ensure that we've gotten at least one call to register the size of the element before we test anything.
3574ffe to
7b770d8
Compare
Doing this in the constructor doesn't work because the FadeText is often created with the FadedText hidden.
Doing a lot of test waiter setup and work isn't worth it here. My concern that the non faded text tests were not accurate because they hadn't had a chance to fully render probably isn't worth the extra overhead. Going back to the waitFor check to get these two tests to pass.
|
Adding some thoughts for posterity about the |
The purpose was to fix ilios/ilios#6532, but I needed to take the entire thing apart so we could remove links only when needed. Took advantage of contextual component, some things we've learned about modifiers, and a new css feature
mask-imageto remove a lot of duplication.Best reviewed as individual commits.