Skip to content

Commit f458049

Browse files
authored
Hotfix: Bring back placeholders on web (#723)
1 parent 1023eab commit f458049

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

WebExample/__tests__/styles.spec.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {test} from '@playwright/test';
1+
import {test, expect} from '@playwright/test';
22
// eslint-disable-next-line import/no-relative-packages
33
import * as TEST_CONST from '../../example/src/testConstants';
4-
import {testMarkdownContentStyle, testMarkdownElementHasComputedStyle} from './utils';
4+
import {setupInput, testMarkdownContentStyle, testMarkdownElementHasComputedStyle} from './utils';
55

66
test.beforeEach(async ({page}) => {
77
await page.goto(TEST_CONST.LOCAL_URL, {waitUntil: 'load'});
@@ -72,3 +72,27 @@ test.describe('markdown content styling', () => {
7272
await testMarkdownElementHasComputedStyle({testContent: 'strikethrough_blockquote', propertyName: 'text-decoration', style: blockquoteStyle, page});
7373
});
7474
});
75+
76+
test.describe('empty input styling', () => {
77+
test.beforeEach(async ({page}) => {
78+
await page.click('[data-testid="clear"]');
79+
});
80+
81+
test('placeholder should have correct text', async ({page}) => {
82+
const placeholder = await page.$eval(`div#${TEST_CONST.INPUT_ID}`, (el) => el.getAttribute('placeholder'));
83+
expect(placeholder).toBe('Type here...');
84+
});
85+
86+
test('empty input should have visible placeholder', async ({page}) => {
87+
const inputLocator = await setupInput(page);
88+
89+
const beforeContent = await inputLocator.evaluate((el) => {
90+
return window.getComputedStyle(el, '::before').getPropertyValue('content');
91+
});
92+
93+
expect([
94+
'"Type here..."', // Chromium/WebKit, resolves attr()
95+
'attr(placeholder)', // Firefox, literal
96+
]).toContain(beforeContent);
97+
});
98+
});

src/web/MarkdownTextInput.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
padding-right: 1px !important;
3131
}
3232

33+
.react-native-live-markdown-input-singleline:empty::before,
34+
.react-native-live-markdown-input-multiline:empty::before {
35+
pointer-events: none;
36+
display: block; /* For Firefox */
37+
content: attr(placeholder);
38+
}
39+
3340
.react-native-live-markdown-input-multiline *[data-type='pre'] {
3441
line-height: 1.3;
3542
display: block;

0 commit comments

Comments
 (0)