Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 00e2728

Browse files
myan9starpit
authored andcommitted
fix: eliminate use of custom <tab> tag
Fixes #3777
1 parent dd9eaff commit 00e2728

File tree

15 files changed

+31
-43
lines changed

15 files changed

+31
-43
lines changed

clients/alternate/plugins/plugin-test/src/test/bottom-input/new-tab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('core new tab from pty active tab via button click', function(this: Com
5252

5353
it('start vi, then new tab via button click', () =>
5454
CLI.command('vi', this.app)
55-
.then(() => this.app.client.waitForExist('tab.visible.xterm-alt-buffer-mode'))
55+
.then(() => this.app.client.waitForExist(`${Selectors.CURRENT_TAB}.xterm-alt-buffer-mode`))
5656
.then(() => this.app.client.click(tabButtonSelector))
5757
.then(() => this.app.client.waitForVisible(Selectors.TAB_SELECTED_N(2)))
5858
.then(() => CLI.waitForSession(this)) // should have an active repl

packages/core/src/webapp/tab.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
import REPL from '../models/repl'
1818
import TabState from '../models/tab-state'
1919

20-
export interface Tab extends HTMLElement {
20+
export interface Tab extends HTMLDivElement {
2121
REPL: REPL
2222
state: TabState
2323
queueListener: EventListener // for input queueing, see queueing.ts
2424
_kui_session: Promise<any>
2525
}
2626

27-
const tabTagPattern = /^tab$/i
28-
2927
export function isTab(node: Element): node is Tab {
30-
return tabTagPattern.test(node.tagName)
28+
return node.classList.contains('kui--tab-content')
3129
}
3230

3331
/**
@@ -58,7 +56,7 @@ export const getTabFromTarget = (target: EventTarget): Tab => {
5856
}
5957

6058
// fallthrough
61-
return document.querySelector('tab.visible')
59+
return document.querySelector('.kui--tab-content.visible')
6260
}
6361

6462
export const getCurrentTab = (): Tab => {

packages/test/src/api/selectors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export const CURRENT_TAB = 'tab.visible'
2-
export const TAB_N = (N: number) => `tab:nth-child(${N})`
1+
export const CURRENT_TAB = '.kui--tab-content.visible'
2+
export const TAB_N = (N: number) => `.kui--tab-content:nth-child(${N})`
33
export const TAB_SELECTED_N = (N: number) => `${TAB_N(N)}.visible`
44

55
export const SIDECAR_BASE = `${CURRENT_TAB} .kui--sidecar`
66
export const SIDECAR_FULLSCREEN = `${CURRENT_TAB} .kui--sidecar.visible.maximized:not(.minimized)`
77
export const PROMPT_BLOCK = `${CURRENT_TAB} .repl .repl-block`
8-
export const BOTTOM_PROMPT_BLOCK = `.kui--input-stripe .repl-block`
8+
export const BOTTOM_PROMPT_BLOCK = `${CURRENT_TAB} .kui--input-stripe .repl-block`
99
export const BOTTOM_PROMPT = `${BOTTOM_PROMPT_BLOCK} input`
1010
export const OOPS = `${CURRENT_TAB} .repl .repl-block .oops`
1111
export const SIDECAR = `${SIDECAR_BASE}.visible:not(.minimized)`

packages/test/src/api/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class TestTable {
9292
try {
9393
await ctx.app.client.waitUntil(async () => {
9494
const watchableJobsRaw = await ctx.app.client.execute(() => {
95-
const tab = document.querySelector('tab.visible') as Tab
95+
const tab = document.querySelector('.kui--tab-content.visible') as Tab
9696
return tab && tab.state && tab.state.jobs
9797
})
9898
const actualJobCount = watchableJobsRaw.value

plugins/plugin-bash-like/src/test/bash-like/pty-copy-paste.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe(`xterm copy paste ${process.env.MOCHA_RUN_TARGET || ''}`, function(this
110110

111111
// wait for vi to come up in alt buffer mode
112112
console.error('CP8')
113-
await this.app.client.waitForExist(`tab.visible.xterm-alt-buffer-mode`)
113+
await this.app.client.waitForExist(`${Selectors.CURRENT_TAB}.xterm-alt-buffer-mode`)
114114

115115
// enter insert mode, and wait for INSERT to appear at the bottom
116116
console.error('CP9')

plugins/plugin-bash-like/src/test/bash-like/vi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe(`xterm vi 1 ${process.env.MOCHA_RUN_TARGET || ''}`, function(this: Comm
4040
await this.app.client.waitForExist(rows(res.count))
4141

4242
// wait for vi to come up in alt buffer mode
43-
await this.app.client.waitForExist(`tab.visible.xterm-alt-buffer-mode`)
43+
await this.app.client.waitForExist(`${Selectors.CURRENT_TAB}.xterm-alt-buffer-mode`)
4444

4545
// enter insert mode, and wait for INSERT to appear at the bottom
4646
let iter = 0
@@ -102,7 +102,7 @@ describe(`xterm vi 2 ${process.env.MOCHA_RUN_TARGET || ''}`, function(this: Comm
102102
await this.app.client.waitForExist(rows(res.count))
103103

104104
// wait for vi to come up in alt buffer mode
105-
await this.app.client.waitForExist(`tab.visible.xterm-alt-buffer-mode`)
105+
await this.app.client.waitForExist(`${Selectors.CURRENT_TAB}.xterm-alt-buffer-mode`)
106106

107107
// :wq
108108
await this.app.client.keys(':wq')

plugins/plugin-bash-like/web/css/static/xterm.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
transition: width 10ms ease-in-out, height 10ms ease-in-out;
3232
}
3333

34-
tab:not(.xterm-alt-buffer-mode) .xterm-container .xterm-screen {
34+
.kui--tab-content:not(.xterm-alt-buffer-mode) .xterm-container .xterm-screen {
3535
height: auto !important;
3636
}
3737

3838
/* alt buffer mode */
39-
tab.xterm-alt-buffer-mode {
39+
.kui--tab-content.xterm-alt-buffer-mode {
4040
.xterm-container .xterm-rows.xterm-focus .xterm-cursor.xterm-cursor-block {
4141
background-color: var(--color-support-01) !important;
4242
}
@@ -87,7 +87,7 @@ tab.xterm-alt-buffer-mode {
8787
}
8888
}
8989

90-
tab:not(.xterm-alt-buffer-mode) .xterm.xterm-empty-row-heuristic .xterm-rows > div:empty {
90+
.kui--tab-content:not(.xterm-alt-buffer-mode) .xterm.xterm-empty-row-heuristic .xterm-rows > div:empty {
9191
display: none;
9292
}
9393

@@ -240,7 +240,7 @@ tab:not(.xterm-alt-buffer-mode) .xterm.xterm-empty-row-heuristic .xterm-rows > d
240240
* only for line wrapping, so that we can reflow them
241241
* naturally. Please see `reflowLineWraps()` in `src/pty/client.ts`
242242
* for the logic that establishes the `.xterm-is-wrapped` property.
243-
*
243+
*
244244
*/
245245
.xterm-terminated .xterm-rows > div {
246246
white-space: pre-wrap;

plugins/plugin-client-common/src/components/TabContent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ export default class TabContent extends React.PureComponent<Props, State> {
205205

206206
public render() {
207207
return (
208-
<tab
208+
<div
209209
ref={c => this.setState({ tab: c as KuiTab })}
210-
className={this.props.active ? 'visible' : ''}
210+
className={'kui--tab-content' + (this.props.active ? ' visible' : '')}
211211
data-tab-id={this.props.uuid}
212212
>
213213
<div className="kui--rows">
@@ -236,7 +236,7 @@ export default class TabContent extends React.PureComponent<Props, State> {
236236
{this.bottom()}
237237
</div>
238238
{this.state.tab && <Confirm tab={this.state.tab} uuid={this.props.uuid} />}
239-
</tab>
239+
</div>
240240
)
241241
}
242242
}

plugins/plugin-client-common/src/components/Terminal/Block/OnKeyDown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ export default async function onKeyDown(this: Input, event: KeyboardEvent) {
9292
if (inBrowser()) {
9393
debug('pageup')
9494
const { height } = document.body.getBoundingClientRect()
95-
document.querySelector('tab.visible .repl-inner').scrollBy(0, -height)
95+
document.querySelector('.kui--tab-content.visible .repl-inner').scrollBy(0, -height)
9696
}
9797
} else if (char === KeyCodes.PAGEDOWN) {
9898
if (inBrowser()) {
9999
debug('pagedown')
100100
const { height } = document.body.getBoundingClientRect()
101-
document.querySelector('tab.visible .repl-inner').scrollBy(0, +height)
101+
document.querySelector('.kui--tab-content.visible .repl-inner').scrollBy(0, +height)
102102
}
103103
} else if (char === KeyCodes.C && event.ctrlKey) {
104104
// Ctrl+C, cancel

plugins/plugin-client-common/src/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ import '../web/css/static/status-stripe.css'
2828
import '../web/css/static/top-tab-stripe.css'
2929
import '../web/css/static/vendor/balloon-css/balloon.min.css'
3030

31-
// we use customized tags since the body view doesn't use a React Component lifecycle for now
32-
declare global {
33-
/* eslint-disable @typescript-eslint/no-namespace */
34-
namespace JSX {
35-
interface IntrinsicElements {
36-
tab: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>
37-
}
38-
}
39-
}
40-
4131
export { default as Search } from './components/Search'
4232
export { default as Loading } from './components/Loading'
4333
export { default as HTMLDom } from './components/Scalar/HTMLDom'

0 commit comments

Comments
 (0)