@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
53 lines (51 loc) • 1.97 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
/**
* @jsxRuntime classic
* @jsx jsx
*/
import React, { PureComponent } from 'react';
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
import { jsx } from '@emotion/react';
import { injectIntl } from 'react-intl';
import { messages } from './messages';
import { inputStyle } from './styles';
// Ignored via go/ees005
// eslint-disable-next-line @repo/internal/react/no-class-components
class ChromeCollapsed extends PureComponent {
constructor(...args) {
super(...args);
_defineProperty(this, "focusHandler", evt => {
/**
* We need this magic for FireFox.
* The reason we need it is, when, in FireFox, we have focus inside input,
* and then we remove that input and move focus to another place programmatically,
* for whatever reason UP/DOWN arrows don't work until you blur and focus editor manually.
*/
if (this.input) {
this.input.blur();
}
if (this.props.onFocus) {
this.props.onFocus(evt);
}
});
_defineProperty(this, "handleInputRef", ref => {
this.input = ref;
});
}
render() {
const placeholder = this.props.text || this.props.intl.formatMessage(messages.chromeCollapsedPlaceholder);
return jsx("input", {
"data-testid": "chrome-collapsed"
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
,
css: inputStyle,
ref: this.handleInputRef,
onFocus: this.focusHandler,
placeholder: placeholder,
"aria-label": this.props.label
});
}
}
// eslint-disable-next-line @typescript-eslint/ban-types
const _default_1 = injectIntl(ChromeCollapsed);
export default _default_1;